Open OscarPoels opened 2 months ago
Voting for Prioritization
Volunteering to Work on This Issue
Hey @OscarPoels 👋 Thank you for taking the time to raise this! Maybe I've misunderstood, but it seems like this is covered in the existing documentation (emphasis mine):
NOTE: Not all rule permissions (e.g., not all of a rule's CIDR blocks) need to be imported for Terraform to manage rule permissions. However, importing some of a rule's permissions but not others, and then making changes to the rule will result in the creation of an additional rule to capture the updated permissions. Rule permissions that were not imported are left intact in the original rule.
Hello @justinretzolk and thank you for your reply, Perhaps there's maybe something I haven't understood on my side, The documentation talks about an existing rule that would be modified, but I'm talking about a rule that doesn't exist anywhere. What's more, if I go back to my example and do a terraform apply by modifying permissions in this rule that don't involve recreating a resource (e.g. adding a description), this doesn't create a new rule but returns an error because it let me import a rule that does not exist:
error: updating Security Group (sg-XXXXXXX) Rule (sgrule-XXXXXXX) description: operation error EC2: UpdateSecurityGroupRuleDescriptionsIngress, https response error StatusCode: 400, RequestID: XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX, api error InvalidPermission. NotFound: The specified rule does not exist in this security group.
Hey @OscarPoels 👋 Thanks for the additional clarification. That makes sense to me. With that in mind, I'm going to remove the needs-triage
, indicating that the issue is now waiting to be prioritized.
Terraform Core Version
1.9.4
AWS Provider Version
5.62.0
Affected Resource(s)
aws_security_group_rule
Expected Behavior
When importing a non existing security group rule, terraform should return
cannot import non-existent remote object
Actual Behavior
Terraform does allow to import a non existing security group rule
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
terraform apply -target='aws_security_group.example_sg' -target='aws_vpc.example_vpc'
tf import 'aws_security_group_rule.allow_port_6443_self' '<your security group ID>_ingress_tcp_6443_6443_self'
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None