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

d/aws_default_tags: Fix regression with null vs. empty map #27377

Merged
merged 3 commits into from
Oct 21, 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/27377.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
data-source/aws_default_tags: Fix regression setting `tags` to `null` instead of an empty map (`{}`) when no `default_tags` are defined
```
6 changes: 1 addition & 5 deletions internal/service/meta/default_tags_data_source.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions internal/service/meta/default_tags_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ func TestAccMetaDefaultTagsDataSource_empty(t *testing.T) {
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Config: acctest.ConfigCompose(
acctest.ConfigDefaultTags_Tags0(),
testAccDefaultTagsDataSourceConfig_basic(),
),
Config: testAccDefaultTagsDataSourceConfig_basic(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "0"),
),
Expand Down Expand Up @@ -109,6 +106,35 @@ func TestAccMetaDefaultTagsDataSource_ignore(t *testing.T) {
})
}

func TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty(t *testing.T) {
dataSourceName := "data.aws_default_tags.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, tfmeta.PseudoServiceID),
CheckDestroy: nil,
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"aws": {
Source: "hashicorp/aws",
VersionConstraint: "4.35.0",
},
},
Config: testAccDefaultTagsDataSourceConfig_basic(),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "tags.%", "0"),
),
},
{
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
Config: testAccDefaultTagsDataSourceConfig_basic(),
PlanOnly: true,
},
},
})
}

func testAccDefaultTagsDataSourceConfig_basic() string {
return `data "aws_default_tags" "test" {}`
}