Skip to content

aws_security_group egress rules are not removed #1555

@thomasbiddle

Description

@thomasbiddle

When using aws_security_group and removing an egress statement; Terraform does not reflect the change. It works fine when adding it; however removing it is completely ignored.

I am unsure how aws_security_group_rule works in this case. I would assume it works fine as it is an individual resource.

Terraform Version

Terraform v0.10.2

Affected Resource(s)

Please list the resources as a list, for example:

  • aws_security_group

Terraform Configuration Files

resource "aws_security_group" "a_security_group" {
  name = "a_security_group"

  vpc_id = "vpc-abcd1234"

  ingress {
    from_port = 443
    to_port   = 443
    protocol  = "tcp"

    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
  tags {
    Name = "a_security_group"
  }
}

Expected Behavior

  • Create security group with egress rule, and terraform apply
  • Group is created
  • Remove egress rule and run terraform apply
  • Security group exists with all rules; however egress rule is removed

Actual Behavior

  • Egress rule is still there; Terraform makes no mention of it.

Steps to Reproduce

  • Create security group with any rules you want, add an egress rule as mentioned in the HCL above.
  • terraform apply
  • Remove the egress statement
  • terraform apply

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/ec2Issues and PRs that pertain to the ec2 service.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions