Use separate TF resources for security group ingress/egress rules #1782
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
Part of https://github.com/cloud-gov/private/issues/1439
We have a problem where Terraform is constantly detecting changes to our
aws_security_group
resources, when in fact nothing is changing except that Terraform thinks the order of thecidr_blocks
values have changed.After looking for an easy fix in the Terraform AWS provider GitHub, I struck out and then went to the documentation page for the
aws_security_group
resource which has this note:In line with those suggestions, I am refactoring the code to use separate
aws_vpc_security_group_ingress_rule
andaws_vpc_security_group_egress_rule
resources to have a separate ingress/egress rule for each CIDR block. I think this refactoring will resolve the issue with Terraform always detecting changes because each IP will effectively create a different resource in Terraform and thus ordering should not matter.security considerations
There should be no material changes to security group ingress/egress, just refactoring how those resources are declared in Terraform.