Naming Conventions
Establish consistent naming patterns for your infrastructure resources.
Consistent naming makes infrastructure easier to understand and manage.
General Principles
- Be descriptive - Names should indicate purpose
- Be consistent - Use the same pattern everywhere
- Be concise - Keep names readable but not too long
- Include context - Environment, region, purpose
Recommended Format
{environment}-{application}-{component}-{region}
Examples
| Resource | Name |
|---|---|
| VPC | prod-webapp-vpc-us-east-1 |
| Security Group | prod-webapp-web-sg |
| EC2 Instance | prod-webapp-api-01 |
| Lambda | prod-webapp-processor |
Environment Prefixes
| Prefix | Environment |
|---|---|
dev | Development |
stg | Staging |
prod | Production |
Character Restrictions
Be aware of AWS naming restrictions:
- Most resources: alphanumeric + hyphens
- S3 buckets: lowercase, globally unique
- IAM roles: alphanumeric +
+=,.@-_
Module Integration
Pass consistent names to modules:
module "vpc" {
source = "..."
name = "${var.environment}-${var.app_name}-vpc"
}