diff --git a/aws/data_source_aws_outposts_outpost.go b/aws/data_source_aws_outposts_outpost.go index c4a1a9eefaa..54f22fa0e6a 100644 --- a/aws/data_source_aws_outposts_outpost.go +++ b/aws/data_source_aws_outposts_outpost.go @@ -14,8 +14,10 @@ func dataSourceAwsOutpostsOutpost() *schema.Resource { Schema: map[string]*schema.Schema{ "arn": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateArn, }, "availability_zone": { Type: schema.TypeString, @@ -76,6 +78,10 @@ func dataSourceAwsOutpostsOutpostRead(d *schema.ResourceData, meta interface{}) continue } + if v, ok := d.GetOk("arn"); ok && v.(string) != aws.StringValue(outpost.OutpostArn) { + continue + } + results = append(results, outpost) } diff --git a/aws/data_source_aws_outposts_outpost_test.go b/aws/data_source_aws_outposts_outpost_test.go index 2b236dfa120..c4bc6899ac4 100644 --- a/aws/data_source_aws_outposts_outpost_test.go +++ b/aws/data_source_aws_outposts_outpost_test.go @@ -56,6 +56,31 @@ func TestAccAWSOutpostsOutpostDataSource_Name(t *testing.T) { }) } +func TestAccAWSOutpostsOutpostDataSource_Arn(t *testing.T) { + sourceDataSourceName := "data.aws_outposts_outpost.source" + dataSourceName := "data.aws_outposts_outpost.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSOutpostsOutposts(t) }, + Providers: testAccProviders, + CheckDestroy: nil, + Steps: []resource.TestStep{ + { + Config: testAccAWSOutpostsOutpostDataSourceConfigArn(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrPair(dataSourceName, "arn", sourceDataSourceName, "arn"), + resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone", sourceDataSourceName, "availability_zone"), + resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone_id", sourceDataSourceName, "availability_zone_id"), + resource.TestCheckResourceAttrPair(dataSourceName, "description", sourceDataSourceName, "description"), + resource.TestCheckResourceAttrPair(dataSourceName, "id", sourceDataSourceName, "id"), + resource.TestCheckResourceAttrPair(dataSourceName, "name", sourceDataSourceName, "name"), + resource.TestCheckResourceAttrPair(dataSourceName, "owner_id", sourceDataSourceName, "owner_id"), + ), + }, + }, + }) +} + func testAccAWSOutpostsOutpostDataSourceConfigId() string { return ` data "aws_outposts_outposts" "test" {} @@ -79,3 +104,17 @@ data "aws_outposts_outpost" "test" { } ` } + +func testAccAWSOutpostsOutpostDataSourceConfigArn() string { + return ` +data "aws_outposts_outposts" "test" {} + +data "aws_outposts_outpost" "source" { + arn = tolist(data.aws_outposts_outposts.test.arns)[0] +} + +data "aws_outposts_outpost" "test" { + arn = data.aws_outposts_outpost.source.arn +} +` +} diff --git a/website/docs/d/outposts_outpost.html.markdown b/website/docs/d/outposts_outpost.html.markdown index 98cd6f434cb..82c2ea1d47b 100644 --- a/website/docs/d/outposts_outpost.html.markdown +++ b/website/docs/d/outposts_outpost.html.markdown @@ -24,12 +24,12 @@ The following arguments are supported: * `id` - (Optional) Identifier of the Outpost. * `name` - (Optional) Name of the Outpost. +* `arn` - (Optional) Amazon Resource Name (ARN). ## Attribute Reference In addition to all arguments above, the following attributes are exported: -* `arn` - Amazon Resource Name (ARN). * `availability_zone` - Availability Zone name. * `availability_zone_id` - Availability Zone identifier. * `description` - Description.