From 73791b47b3e5eb6f5a08a0a58459a2129d4662d7 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Tue, 16 Aug 2016 21:05:27 +0100 Subject: [PATCH] aws: Implement naming changes for aws_elb_service_account --- .../data_source_aws_elb_account_id_test.go | 38 ------------------- ...=> data_source_aws_elb_service_account.go} | 6 +-- ...ata_source_aws_elb_service_account_test.go | 38 +++++++++++++++++++ builtin/providers/aws/provider.go | 2 +- ...down => elb_service_account.html.markdown} | 19 +++++----- website/source/layouts/aws.erb | 4 +- 6 files changed, 54 insertions(+), 53 deletions(-) delete mode 100644 builtin/providers/aws/data_source_aws_elb_account_id_test.go rename builtin/providers/aws/{data_source_aws_elb_account_id.go => data_source_aws_elb_service_account.go} (85%) create mode 100644 builtin/providers/aws/data_source_aws_elb_service_account_test.go rename website/source/docs/providers/aws/d/{elb_account_id.html.markdown => elb_service_account.html.markdown} (60%) diff --git a/builtin/providers/aws/data_source_aws_elb_account_id_test.go b/builtin/providers/aws/data_source_aws_elb_account_id_test.go deleted file mode 100644 index 72cfc3caf..000000000 --- a/builtin/providers/aws/data_source_aws_elb_account_id_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package aws - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccAWSElbAccountId_basic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckAwsElbAccountIdConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.aws_elb_account_id.main", "id", "797873946194"), - ), - }, - resource.TestStep{ - Config: testAccCheckAwsElbAccountIdExplicitRegionConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.aws_elb_account_id.regional", "id", "156460612806"), - ), - }, - }, - }) -} - -const testAccCheckAwsElbAccountIdConfig = ` -data "aws_elb_account_id" "main" { } -` - -const testAccCheckAwsElbAccountIdExplicitRegionConfig = ` -data "aws_elb_account_id" "regional" { - region = "eu-west-1" -} -` diff --git a/builtin/providers/aws/data_source_aws_elb_account_id.go b/builtin/providers/aws/data_source_aws_elb_service_account.go similarity index 85% rename from builtin/providers/aws/data_source_aws_elb_account_id.go rename to builtin/providers/aws/data_source_aws_elb_service_account.go index f05df4611..8101dac09 100644 --- a/builtin/providers/aws/data_source_aws_elb_account_id.go +++ b/builtin/providers/aws/data_source_aws_elb_service_account.go @@ -23,9 +23,9 @@ var elbAccountIdPerRegionMap = map[string]string{ "us-west-2": "797873946194", } -func dataSourceAwsElbAccountId() *schema.Resource { +func dataSourceAwsElbServiceAccount() *schema.Resource { return &schema.Resource{ - Read: dataSourceAwsElbAccountIdRead, + Read: dataSourceAwsElbServiceAccountRead, Schema: map[string]*schema.Schema{ "region": &schema.Schema{ @@ -36,7 +36,7 @@ func dataSourceAwsElbAccountId() *schema.Resource { } } -func dataSourceAwsElbAccountIdRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceAwsElbServiceAccountRead(d *schema.ResourceData, meta interface{}) error { region := meta.(*AWSClient).region if v, ok := d.GetOk("region"); ok { region = v.(string) diff --git a/builtin/providers/aws/data_source_aws_elb_service_account_test.go b/builtin/providers/aws/data_source_aws_elb_service_account_test.go new file mode 100644 index 000000000..bf818fe88 --- /dev/null +++ b/builtin/providers/aws/data_source_aws_elb_service_account_test.go @@ -0,0 +1,38 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSElbServiceAccount_basic(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckAwsElbServiceAccountConfig, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.aws_elb_service_account.main", "id", "797873946194"), + ), + }, + resource.TestStep{ + Config: testAccCheckAwsElbServiceAccountExplicitRegionConfig, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("data.aws_elb_service_account.regional", "id", "156460612806"), + ), + }, + }, + }) +} + +const testAccCheckAwsElbServiceAccountConfig = ` +data "aws_elb_service_account" "main" { } +` + +const testAccCheckAwsElbServiceAccountExplicitRegionConfig = ` +data "aws_elb_service_account" "regional" { + region = "eu-west-1" +} +` diff --git a/builtin/providers/aws/provider.go b/builtin/providers/aws/provider.go index 8b3927234..950210363 100644 --- a/builtin/providers/aws/provider.go +++ b/builtin/providers/aws/provider.go @@ -144,7 +144,7 @@ func Provider() terraform.ResourceProvider { "aws_availability_zones": dataSourceAwsAvailabilityZones(), "aws_caller_identity": dataSourceAwsCallerIdentity(), "aws_ecs_container_definition": dataSourceAwsEcsContainerDefinition(), - "aws_elb_account_id": dataSourceAwsElbAccountId(), + "aws_elb_service_account": dataSourceAwsElbServiceAccount(), "aws_iam_policy_document": dataSourceAwsIamPolicyDocument(), "aws_ip_ranges": dataSourceAwsIPRanges(), "aws_redshift_service_account": dataSourceAwsRedshiftServiceAccount(), diff --git a/website/source/docs/providers/aws/d/elb_account_id.html.markdown b/website/source/docs/providers/aws/d/elb_service_account.html.markdown similarity index 60% rename from website/source/docs/providers/aws/d/elb_account_id.html.markdown rename to website/source/docs/providers/aws/d/elb_service_account.html.markdown index 7552c8bf1..178d7c3ad 100644 --- a/website/source/docs/providers/aws/d/elb_account_id.html.markdown +++ b/website/source/docs/providers/aws/d/elb_service_account.html.markdown @@ -1,20 +1,20 @@ --- layout: "aws" -page_title: "AWS: aws_elb_account_id" -sidebar_current: "docs-aws-datasource-elb-account-id" +page_title: "AWS: aws_elb_service_account" +sidebar_current: "docs-aws-datasource-elb-service-account" description: |- - Get AWS Elastic Load Balancing Account ID + Get AWS Elastic Load Balancing Service Account --- -# aws\_elb\_account\_id +# aws\_elb\_service\_account -Use this data source to get the Account ID of the [AWS Elastic Load Balancing Account](http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy) +Use this data source to get the Account ID of the [AWS Elastic Load Balancing Service Account](http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy) in a given region for the purpose of whitelisting in S3 bucket policy. ## Example Usage ``` -data "aws_elb_account_id" "main" { } +data "aws_elb_service_account" "main" { } resource "aws_s3_bucket" "elb_logs" { bucket = "my-elb-tf-test-bucket" @@ -32,7 +32,7 @@ resource "aws_s3_bucket" "elb_logs" { "Resource": "arn:aws:s3:::my-elb-tf-test-bucket/AWSLogs/*", "Principal": { "AWS": [ - "${data.aws_elb_account_id.main.id}" + "${data.aws_elb_service_account.main.id}" ] } } @@ -61,9 +61,10 @@ resource "aws_elb" "bar" { ## Argument Reference -* `region` - (Optional) Region of a given AWS ELB Account +* `region` - (Optional) Name of the region whose AWS ELB account ID is desired. + Defaults to the region from the AWS provider configuration. ## Attributes Reference -* `id` - Account ID +* `id` - The ID of the AWS ELB service account in the selected region. diff --git a/website/source/layouts/aws.erb b/website/source/layouts/aws.erb index 9d038347c..edd9a9fea 100644 --- a/website/source/layouts/aws.erb +++ b/website/source/layouts/aws.erb @@ -26,8 +26,8 @@ > aws_ecs_container_definition - > - aws_elb_account_id + > + aws_elb_service_account > aws_iam_policy_document