github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/aws/data_source_aws_redshift_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/redshift/latest/mgmt/db-auditing.html#db-auditing-enable-logging
    10  var redshiftServiceAccountPerRegionMap = map[string]string{
    11  	"us-east-1":      "193672423079",
    12  	"us-east-2":      "391106570357",
    13  	"us-west-1":      "262260360010",
    14  	"us-west-2":      "902366379725",
    15  	"ap-south-1":     "865932855811",
    16  	"ap-northeast-2": "760740231472",
    17  	"ap-southeast-1": "361669875840",
    18  	"ap-southeast-2": "762762565011",
    19  	"ap-northeast-1": "404641285394",
    20  	"eu-central-1":   "053454850223",
    21  	"eu-west-1":      "210876761215",
    22  }
    23  
    24  func dataSourceAwsRedshiftServiceAccount() *schema.Resource {
    25  	return &schema.Resource{
    26  		Read: dataSourceAwsRedshiftServiceAccountRead,
    27  
    28  		Schema: map[string]*schema.Schema{
    29  			"region": &schema.Schema{
    30  				Type:     schema.TypeString,
    31  				Optional: true,
    32  			},
    33  		},
    34  	}
    35  }
    36  
    37  func dataSourceAwsRedshiftServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
    38  	region := meta.(*AWSClient).region
    39  	if v, ok := d.GetOk("region"); ok {
    40  		region = v.(string)
    41  	}
    42  
    43  	if accid, ok := redshiftServiceAccountPerRegionMap[region]; ok {
    44  		d.SetId(accid)
    45  		return nil
    46  	}
    47  
    48  	return fmt.Errorf("Unknown region (%q)", region)
    49  }