github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/aws/data_source_aws_caller_identity.go (about) 1 package aws 2 3 import ( 4 "fmt" 5 "log" 6 "time" 7 8 "github.com/hashicorp/terraform/helper/schema" 9 ) 10 11 func dataSourceAwsCallerIdentity() *schema.Resource { 12 return &schema.Resource{ 13 Read: dataSourceAwsCallerIdentityRead, 14 15 Schema: map[string]*schema.Schema{ 16 "account_id": { 17 Type: schema.TypeString, 18 Computed: true, 19 }, 20 }, 21 } 22 } 23 24 func dataSourceAwsCallerIdentityRead(d *schema.ResourceData, meta interface{}) error { 25 client := meta.(*AWSClient) 26 27 log.Printf("[DEBUG] Reading Caller Identity.") 28 d.SetId(time.Now().UTC().String()) 29 30 if client.accountid == "" { 31 log.Println("[DEBUG] No Account ID available, failing") 32 return fmt.Errorf("No AWS Account ID is available to the provider. Please ensure that\n" + 33 "skip_requesting_account_id is not set on the AWS provider.") 34 } 35 36 log.Printf("[DEBUG] Setting AWS Account ID to %s.", client.accountid) 37 d.Set("account_id", meta.(*AWSClient).accountid) 38 39 return nil 40 }