Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'rack_elevation' attribute to aws_outposts_asset data source #25822

Merged
merged 6 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.