github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/aws/data_source_aws_elb_service_account.go (about)

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/hashicorp/terraform/helper/schema"
     7  )
     8  
     9  // See http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy
    10  var elbAccountIdPerRegionMap = map[string]string{
    11  	"ap-northeast-1": "582318560864",
    12  	"ap-northeast-2": "600734575887",
    13  	"ap-south-1":     "718504428378",
    14  	"ap-southeast-1": "114774131450",
    15  	"ap-southeast-2": "783225319266",
    16  	"ca-central-1":   "985666609251",
    17  	"cn-north-1":     "638102146993",
    18  	"eu-central-1":   "054676820928",
    19  	"eu-west-1":      "156460612806",
    20  	"eu-west-2":      "652711504416",
    21  	"sa-east-1":      "507241528517",
    22  	"us-east-1":      "127311923021",
    23  	"us-east-2":      "033677994240",
    24  	"us-gov-west":    "048591011584",
    25  	"us-west-1":      "027434742980",
    26  	"us-west-2":      "797873946194",
    27  }
    28  
    29  func dataSourceAwsElbServiceAccount() *schema.Resource {
    30  	return &schema.Resource{
    31  		Read: dataSourceAwsElbServiceAccountRead,
    32  
    33  		Schema: map[string]*schema.Schema{
    34  			"region": &schema.Schema{
    35  				Type:     schema.TypeString,
    36  				Optional: true,
    37  			},
    38  			"arn": &schema.Schema{
    39  				Type:     schema.TypeString,
    40  				Computed: true,
    41  			},
    42  		},
    43  	}
    44  }
    45  
    46  func dataSourceAwsElbServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
    47  	region := meta.(*AWSClient).region
    48  	if v, ok := d.GetOk("region"); ok {
    49  		region = v.(string)
    50  	}
    51  
    52  	if accid, ok := elbAccountIdPerRegionMap[region]; ok {
    53  		d.SetId(accid)
    54  
    55  		d.Set("arn", "arn:aws:iam::"+accid+":root")
    56  
    57  		return nil
    58  	}
    59  
    60  	return fmt.Errorf("Unknown region (%q)", region)
    61  }