-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/aws: Fix EC2 Classic SG Rule issue #5533
Conversation
Fixes an issue where security groups would fail to update after applying an initial security_group, because we were improperly saving the id of the group and not the name (EC2 Classic only). This is a PR combining #4983 and #5184 . It's majority @ephemeralsnow's work.
"to_port": int64(443), | ||
"security_groups": schema.NewSet(schema.HashString, []interface{}{ | ||
"ec2_classic", | ||
"amazon-elb/amazon-elb-sg", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me read the unit test diffs here? Trying to figure out the narrative of "when I do this, then I get this" and having trouble. Could use a bit of hand holding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This chuck matches up with the newly added ec2.IpPermission
block:
&ec2.IpPermission{
IpProtocol: aws.String("tcp"),
FromPort: aws.Int64(int64(443)),
ToPort: aws.Int64(int64(443)),
UserIdGroupPairs: []*ec2.UserIdGroupPair{
// Classic
&ec2.UserIdGroupPair{
UserId: aws.String("12345"),
GroupId: aws.String("sg-33333"),
GroupName: aws.String("ec2_classic"),
},
&ec2.UserIdGroupPair{
UserId: aws.String("amazon-elb"),
GroupId: aws.String("sg-d2c979d3"),
GroupName: aws.String("amazon-elb-sg"),
},
},
}
It represents a security group in EC2 Classic with two name references, one to a group named ec2_classic
and another is the special Amazon ELB security group.
@@ -256,7 +279,7 @@ func TestExpandIPPerms_nonVPC(t *testing.T) { | |||
GroupName: aws.String("sg-22222"), | |||
}, | |||
&ec2.UserIdGroupPair{ | |||
GroupName: aws.String("sg-22222"), | |||
GroupName: aws.String("sg-11111"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious - why are all these SG ids changing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are typo fixes. The original tests never checked the second IP Pair returned, but now they do. As such, I'm sure this typo was revealed (you can't add the same security group twice)
Ok @catsby a few inline comments for ya! ⛵ |
Test results:
|
LGTM |
I can confirm that this fixes my problem in #5532 I also noticed that EC2-Classic forces you to use SG names instead of SG ids but this is not documented in the Terraform documentation. Having a field called |
provider/aws: Fix EC2 Classic SG Rule issue
@catsby Thank you for your support. |
@ephemeralsnow thank you for your contribution! We ❤️ our contributors and users 😄 |
I'm going to lock this issue 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 similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Fixes an issue where security groups would fail to update after applying an
initial security_group, because we were improperly saving the id of the group
and not the name (EC2 Classic only).
This is a PR combining #4983 and #5184 . It's majority @ephemeralsnow's work.
Fixing: