From 7109b8c770055c3fbf3432f2f5fca3aa486151e3 Mon Sep 17 00:00:00 2001 From: Alek Storm Date: Fri, 8 Aug 2014 11:42:32 -0700 Subject: [PATCH] Implement specification of AWS security groups in ingress rules as / --- builtin/providers/aws/structure.go | 7 ++++++- builtin/providers/aws/structure_test.go | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index a8be14675..e5e2e5eef 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -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) } diff --git a/builtin/providers/aws/structure_test.go b/builtin/providers/aws/structure_test.go index 9d438da2c..776f40398 100644 --- a/builtin/providers/aws/structure_test.go +++ b/builtin/providers/aws/structure_test.go @@ -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", + }, }, }