Skip to content

Commit

Permalink
Merge pull request #25822 from silvaalbert/f-aws-outposts-asset-eleva…
Browse files Browse the repository at this point in the history
…tion

add 'rack_elevation' attribute to aws_outposts_asset data source
  • Loading branch information
ewbankkit committed Jul 15, 2022
2 parents 8852737 + 0a01b58 commit ef39574
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/25822.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
data/aws_outposts_asset: Add `rack_elevation` attribute
```
5 changes: 5 additions & 0 deletions internal/service/outposts/outpost_asset_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func DataSourceOutpostAsset() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"rack_elevation": {
Type: schema.TypeInt,
Computed: true,
},
"rack_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -78,6 +82,7 @@ func DataSourceOutpostAssetRead(d *schema.ResourceData, meta interface{}) error
d.Set("asset_id", asset.AssetId)
d.Set("asset_type", asset.AssetType)
d.Set("host_id", asset.ComputeAttributes.HostId)
d.Set("rack_elevation", asset.AssetLocation.RackElevation)
d.Set("rack_id", asset.RackId)
return nil
}
7 changes: 4 additions & 3 deletions internal/service/outposts/outpost_asset_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
)

func TestAccOutpostsAssetDataSource_id(t *testing.T) {
func TestAccOutpostsAssetDataSource_basic(t *testing.T) {
dataSourceName := "data.aws_outposts_asset.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckOutpostsOutposts(t) },
ErrorCheck: acctest.ErrorCheck(t, outposts.EndpointsID),
ProviderFactories: acctest.ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccOutpostAssetDataSourceConfig_id(),
Config: testAccOutpostAssetDataSourceConfig_basic(),
Check: resource.ComposeTestCheckFunc(
acctest.MatchResourceAttrRegionalARN(dataSourceName, "arn", "outposts", regexp.MustCompile(`outpost/.+`)),
resource.TestMatchResourceAttr(dataSourceName, "asset_id", regexp.MustCompile(`^(\w+)$`)),
resource.TestCheckResourceAttrSet(dataSourceName, "asset_type"),
resource.TestMatchResourceAttr(dataSourceName, "rack_elevation", regexp.MustCompile(`^[\S \n]+$`)),
resource.TestMatchResourceAttr(dataSourceName, "rack_id", regexp.MustCompile(`^[\S \n]+$`)),
),
},
},
})
}

func testAccOutpostAssetDataSourceConfig_id() string {
func testAccOutpostAssetDataSourceConfig_basic() string {
return `
data "aws_outposts_outposts" "test" {}
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/outposts_asset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ In addition to all arguments above, the following attributes are exported:

* `asset_type` - The type of the asset.
* `host_id` - The host ID of the Dedicated Hosts on the asset, if a Dedicated Host is provisioned.
* `rack_elevation` - The position of an asset in a rack measured in rack units.
* `rack_id` - The rack ID of the asset.

0 comments on commit ef39574

Please sign in to comment.