2016-08-16 11:17:53 +02:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
)
|
|
|
|
|
|
|
|
// See http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy
|
|
|
|
var elbAccountIdPerRegionMap = map[string]string{
|
|
|
|
"ap-northeast-1": "582318560864",
|
|
|
|
"ap-northeast-2": "600734575887",
|
|
|
|
"ap-south-1": "718504428378",
|
|
|
|
"ap-southeast-1": "114774131450",
|
|
|
|
"ap-southeast-2": "783225319266",
|
2016-12-09 10:35:07 +01:00
|
|
|
"ca-central-1": "985666609251",
|
2016-08-16 11:17:53 +02:00
|
|
|
"cn-north-1": "638102146993",
|
|
|
|
"eu-central-1": "054676820928",
|
|
|
|
"eu-west-1": "156460612806",
|
2016-12-14 10:33:58 +01:00
|
|
|
"eu-west-2": "652711504416",
|
2016-08-16 11:17:53 +02:00
|
|
|
"sa-east-1": "507241528517",
|
|
|
|
"us-east-1": "127311923021",
|
2016-10-18 10:31:57 +02:00
|
|
|
"us-east-2": "033677994240",
|
2016-08-16 11:17:53 +02:00
|
|
|
"us-gov-west": "048591011584",
|
|
|
|
"us-west-1": "027434742980",
|
|
|
|
"us-west-2": "797873946194",
|
|
|
|
}
|
|
|
|
|
2016-08-16 22:05:27 +02:00
|
|
|
func dataSourceAwsElbServiceAccount() *schema.Resource {
|
2016-08-16 11:17:53 +02:00
|
|
|
return &schema.Resource{
|
2016-08-16 22:05:27 +02:00
|
|
|
Read: dataSourceAwsElbServiceAccountRead,
|
2016-08-16 11:17:53 +02:00
|
|
|
|
|
|
|
Schema: map[string]*schema.Schema{
|
2017-01-23 17:30:28 +01:00
|
|
|
"region": {
|
2016-08-16 11:17:53 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
},
|
2017-01-23 17:30:28 +01:00
|
|
|
"arn": {
|
2016-09-11 20:13:58 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Computed: true,
|
|
|
|
},
|
2016-08-16 11:17:53 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-16 22:05:27 +02:00
|
|
|
func dataSourceAwsElbServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
|
2016-08-16 11:17:53 +02:00
|
|
|
region := meta.(*AWSClient).region
|
|
|
|
if v, ok := d.GetOk("region"); ok {
|
|
|
|
region = v.(string)
|
|
|
|
}
|
|
|
|
|
|
|
|
if accid, ok := elbAccountIdPerRegionMap[region]; ok {
|
|
|
|
d.SetId(accid)
|
2016-09-11 20:13:58 +02:00
|
|
|
|
2017-01-23 17:30:28 +01:00
|
|
|
d.Set("arn", fmt.Sprintf("arn:%s:iam::%s:root", meta.(*AWSClient).partition, accid))
|
2016-09-11 20:13:58 +02:00
|
|
|
|
2016-08-16 11:17:53 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Errorf("Unknown region (%q)", region)
|
|
|
|
}
|