-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add lifecycle to security_group_rule #246
Conversation
This PR has been automatically marked as stale because it has been open 30 days |
Don't stale |
@rafaljanicki There is a subtle problem with this request. Your change will be successful on the initial apply and adding additional rules. However, you must consider a side effect of creating resources with
Please see #245 for more information. I developed the aws-security-group-v2 module with |
@rafaljanicki A workaround might be to create a second security group with this module and perform a blue/green migration i.e. first apply the blue, second the green security group with the new rule and third destroy blue security group/rules. I recognize that this would only work with resource(s) that support multiple security group attachments. You may also be able to achieve the same effect with this module by using module "web_server_sg" {
source = "terraform-aws-modules/security-group/aws"
name_prefix = join("-", [local.name, 5, "blue"])
# Force a SG level CBD with a name change
# name_prefix = join("-", [local.name, 5, "green"])
description = "Security group for web-server with HTTP ports open within VPC"
vpc_id = "vpc-12345678"
ingress_cidr_blocks = ["10.10.0.0/16"]
# ingress_ipv6_cidr_blocks = ["2001:db8::/64"]
}
resource "aws_network_interface" "web_server_eni" {
subnet_id = data.aws_subnet.default.id
private_ips = [cidrhost(data.aws_subnet.default.cidr_block, 10)]
security_groups = [module.web_server_sg.security_group_id]
} This still does not work with computed inputs or security groups that need to preserve the ID (e.g. load balancers). For this, a suitable workaround is to perform a blue/green with module rules similar to the rules_only example. |
This PR has been automatically marked as stale because it has been open 30 days |
This PR was automatically closed because of stale in 10 days |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
I've added a lifecycle rule to create a security group rule before destroying
Motivation and Context
This is related to an error
The specified rule does not exist in this security group.
which can be fixed by hashicorp/terraform-provider-aws#12420 (comment)