github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/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  	"cn-north-1":     "638102146993",
    17  	"eu-central-1":   "054676820928",
    18  	"eu-west-1":      "156460612806",
    19  	"sa-east-1":      "507241528517",
    20  	"us-east-1":      "127311923021",
    21  	"us-east-2":      "033677994240",
    22  	"us-gov-west":    "048591011584",
    23  	"us-west-1":      "027434742980",
    24  	"us-west-2":      "797873946194",
    25  }
    26  
    27  func dataSourceAwsElbServiceAccount() *schema.Resource {
    28  	return &schema.Resource{
    29  		Read: dataSourceAwsElbServiceAccountRead,
    30  
    31  		Schema: map[string]*schema.Schema{
    32  			"region": &schema.Schema{
    33  				Type:     schema.TypeString,
    34  				Optional: true,
    35  			},
    36  			"arn": &schema.Schema{
    37  				Type:     schema.TypeString,
    38  				Computed: true,
    39  			},
    40  		},
    41  	}
    42  }
    43  
    44  func dataSourceAwsElbServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
    45  	region := meta.(*AWSClient).region
    46  	if v, ok := d.GetOk("region"); ok {
    47  		region = v.(string)
    48  	}
    49  
    50  	if accid, ok := elbAccountIdPerRegionMap[region]; ok {
    51  		d.SetId(accid)
    52  
    53  		d.Set("arn", "arn:aws:iam::"+accid+":root")
    54  
    55  		return nil
    56  	}
    57  
    58  	return fmt.Errorf("Unknown region (%q)", region)
    59  }