Review security group descriptions

Document the purpose and intended users of the security group.

Description

When you create a security group, use description to identify the workload it serves. If you omit it, Terraform uses Managed by Terraform.

Potential impact

Several groups with the same generic description are easy to confuse during assignment or cleanup.

Remediation

Changing an existing group’s description makes Terraform replace it. Check the plan. To keep the old group active during replacement, create the new group under a different name in the same VPC. Transfer the required rules, update references and attachments, and verify connectivity before removing the old group. Use tags for classifications that change often.

Examples

Both examples use app-sg and aws_vpc.main. The second identifies the application servers the group serves, using characters AWS accepts.

Before

hcl
resource "aws_security_group" "app" {
  name   = "app-sg"
  vpc_id = aws_vpc.main.id
}

After

hcl
resource "aws_security_group" "app" {
  name        = "app-sg"
  description = "Application server security group"
  vpc_id      = aws_vpc.main.id
}

References