Chapter 1 · Practice 3 of 4
Name resources with descriptive nouns, without repeating the type
From Structure and style
Why it matters
A resource address already contains its type, so aws_instance.web_server_instance says "instance" twice. The style guide recommends descriptive nouns with underscores, and not repeating the resource type in the name.
| Avoid | Prefer |
|---|---|
aws_s3_bucket.s3_bucket | aws_s3_bucket.invoices |
aws_instance.web-server | aws_instance.web |
aws_security_group.sg1 | aws_security_group.database |
Inside a block, keep a predictable order: count or for_each first, then plain arguments, then nested blocks, then lifecycle, then depends_on. The same order everywhere makes diffs smaller and reviews faster.
Avoid
- Hyphens in resource names: use underscores
- Generic names like
this,mainorsg1in root modules