Merge pull request #170 from alekstorm/aws-security-group-owner

Implement specification of AWS security groups in ingress rules as <owner>/<id>
This commit is contained in:
Jack Pearkes 2014-08-19 09:42:05 -07:00
commit d99e475ea2
2 changed files with 16 additions and 2 deletions

View File

@ -81,8 +81,13 @@ func expandIPPerms(configured []interface{}) ([]ec2.IPPerm, error) {
gs := expandStringList(secGroups)
for _, g := range gs {
ownerId, id := "", g
if items := strings.Split(g, "/"); len(items) > 1 {
ownerId, id = items[0], items[1]
}
newG := ec2.UserSecurityGroup{
Id: g,
Id: id,
OwnerId: ownerId,
}
expandedGroups = append(expandedGroups, newG)
}

View File

@ -26,8 +26,9 @@ func testConf() map[string]string {
"ingress.0.to_port": "-1",
"ingress.0.cidr_blocks.#": "1",
"ingress.0.cidr_blocks.0": "0.0.0.0/0",
"ingress.0.security_groups.#": "1",
"ingress.0.security_groups.#": "2",
"ingress.0.security_groups.0": "sg-11111",
"ingress.0.security_groups.1": "foo/sg-22222",
}
}
@ -47,6 +48,10 @@ func Test_expandIPPerms(t *testing.T) {
ec2.UserSecurityGroup{
Id: "sg-11111",
},
ec2.UserSecurityGroup{
OwnerId: "foo",
Id: "sg-22222",
},
},
}
@ -92,6 +97,10 @@ func Test_expandIPPerms_NoCidr(t *testing.T) {
ec2.UserSecurityGroup{
Id: "sg-11111",
},
ec2.UserSecurityGroup{
OwnerId: "foo",
Id: "sg-22222",
},
},
}