Export AWS ELB service account ARN (#8700)

This commit is contained in:
Steve Hoeksema 2016-09-12 06:13:58 +12:00 committed by Radek Simko
parent 291f298535
commit 1d04cdb9bc
3 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,10 @@ func dataSourceAwsElbServiceAccount() *schema.Resource {
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
}, },
"arn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
}, },
} }
} }
@ -44,6 +48,9 @@ func dataSourceAwsElbServiceAccountRead(d *schema.ResourceData, meta interface{}
if accid, ok := elbAccountIdPerRegionMap[region]; ok { if accid, ok := elbAccountIdPerRegionMap[region]; ok {
d.SetId(accid) d.SetId(accid)
d.Set("arn", "arn:aws:iam::"+accid+":root")
return nil return nil
} }

View File

@ -15,12 +15,14 @@ func TestAccAWSElbServiceAccount_basic(t *testing.T) {
Config: testAccCheckAwsElbServiceAccountConfig, Config: testAccCheckAwsElbServiceAccountConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_elb_service_account.main", "id", "797873946194"), resource.TestCheckResourceAttr("data.aws_elb_service_account.main", "id", "797873946194"),
resource.TestCheckResourceAttr("data.aws_elb_service_account.main", "arn", "arn:aws:iam::797873946194:root"),
), ),
}, },
resource.TestStep{ resource.TestStep{
Config: testAccCheckAwsElbServiceAccountExplicitRegionConfig, Config: testAccCheckAwsElbServiceAccountExplicitRegionConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_elb_service_account.regional", "id", "156460612806"), resource.TestCheckResourceAttr("data.aws_elb_service_account.regional", "id", "156460612806"),
resource.TestCheckResourceAttr("data.aws_elb_service_account.regional", "arn", "arn:aws:iam::156460612806:root"),
), ),
}, },
}, },

View File

@ -68,3 +68,4 @@ resource "aws_elb" "bar" {
## Attributes Reference ## Attributes Reference
* `id` - The ID of the AWS ELB service account in the selected region. * `id` - The ID of the AWS ELB service account in the selected region.
* `arn` - The ARN of the AWS ELB service account in the selected region.