saif-utilities / examples / naming-database¶
This example demonstrates how to use the database naming module to generate valid Azure Cosmos DB account names according to Azure naming conventions.
What This Example Shows¶
This example demonstrates:
- Basic database naming with minimal configuration
- Environment and tenant specific naming
- Custom prefixes and suffixes for organizational standards
- Organization and owner fields for team identification
- Unique suffix generation for avoiding naming conflicts
- Actual Cosmos DB deployment using the generated names
Azure Cosmos DB Naming Requirements¶
The naming module ensures all generated names comply with Azure Cosmos DB naming rules: - Length: 3-44 characters - Characters: Letters, numbers, and hyphens - Must start and end with alphanumeric character - Hyphens allowed in the middle - Case-insensitive (but preserved)
Usage¶
-
Initialize Terraform:
-
Review the plan:
-
Apply the configuration:
-
View the generated names:
Example Outputs¶
Based on the configurations in this example, you might see names like:
- Basic:
Myapp - Environment + tenant:
ProdContosoWebapp - Custom Prefix/Suffix:
CorpDataTestFabrikamAnalyticsPrimaryV1 - Organization + Owner:
SaifDatateamEnterprisePlatform - With Unique Suffix:
StagingAcmeMicroserviceAbc123(suffix varies)
Customization¶
You can customize the naming by adjusting:
- project_id: Your application/project identifier
- environment_short_name: Environment (dev, test, prod, staging)
- tenant: Your organization or tenant name
- organization_name: Your organization name
- owner_name: Team or owner name
- prefix: List of prefixes to add
- suffix: List of suffixes to add
- unique_length: Length of unique suffix (0 to disable)
- unique_include_numbers: Whether to include numbers in unique suffix
Resource Group¶
This example creates a resource group named rg-module-database in West US 2 for the demonstration. In a real scenario, you would typically use an existing resource group or integrate this into your broader infrastructure.
Clean Up¶
To remove all resources created by this example:
Files¶
main.tf: Main configuration with all examplesREADME.md: This documentation file