Skip to content

Commit

Permalink
providers/aws: can add remove individual cidr/groups in security group
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Aug 21, 2014
1 parent 9ecfdc3 commit 200f7c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions builtin/providers/aws/resource_aws_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,17 @@ func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) er

// TODO: We need to handle partial state better in the in-between
// in this update.
if len(add) > 0 {
// Authorize the new rules
_, err := ec2conn.AuthorizeSecurityGroup(group, add)
if len(remove) > 0 {
// Revoke the old rules
_, err = ec2conn.RevokeSecurityGroup(group, remove)
if err != nil {
return fmt.Errorf("Error authorizing security group ingress rules: %s", err)
}
}

if len(remove) > 0 {
// Revoke the old rules
_, err = ec2conn.RevokeSecurityGroup(group, remove)
if len(add) > 0 {
// Authorize the new rules
_, err := ec2conn.AuthorizeSecurityGroup(group, add)
if err != nil {
return fmt.Errorf("Error authorizing security group ingress rules: %s", err)
}
Expand Down
10 changes: 5 additions & 5 deletions builtin/providers/aws/resource_aws_security_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ func testAccCheckAWSSecurityGroupAttributesChanged(group *ec2.SecurityGroupInfo)
},
ec2.IPPerm{
FromPort: 80,
ToPort: 1234,
ToPort: 8000,
Protocol: "tcp",
SourceIPs: []string{"10.0.0.0/8"},
SourceIPs: []string{"0.0.0.0/0", "10.0.0.0/8"},
},
}

Expand All @@ -262,7 +262,7 @@ func testAccCheckAWSSecurityGroupAttributesChanged(group *ec2.SecurityGroupInfo)
p)
}

if group.IPPerms[0].ToPort == 1234 {
if group.IPPerms[0].ToPort == 8000 {
group.IPPerms[1], group.IPPerms[0] =
group.IPPerms[0], group.IPPerms[1]
}
Expand Down Expand Up @@ -307,8 +307,8 @@ resource "aws_security_group" "web" {
ingress {
protocol = "tcp"
from_port = 80
to_port = 1234
cidr_blocks = ["10.0.0.0/8"]
to_port = 8000
cidr_blocks = ["10.0.0.0/8", "0.0.0.0/0"]
}
}
`
Expand Down

0 comments on commit 200f7c4

Please sign in to comment.