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

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Oct 21, 2022

Description

Fixes a v4.36.0 regression where the aws_default_tags data source returns null vs. an empty map ({}) when no default_tags are configured.

Relations

Closes #27372.
Relates #27221.

Output from Acceptance Testing

N.B. unset TF_CLI_CONFIG_FILE before running.

% make testacc TESTARGS='-run=TestAccMetaDefaultTagsDataSource_' PKG=meta 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/meta/... -v -count 1 -parallel 20  -run=TestAccMetaDefaultTagsDataSource_ -timeout 180m
=== RUN   TestAccMetaDefaultTagsDataSource_basic
=== PAUSE TestAccMetaDefaultTagsDataSource_basic
=== RUN   TestAccMetaDefaultTagsDataSource_empty
=== PAUSE TestAccMetaDefaultTagsDataSource_empty
=== RUN   TestAccMetaDefaultTagsDataSource_multiple
=== PAUSE TestAccMetaDefaultTagsDataSource_multiple
=== RUN   TestAccMetaDefaultTagsDataSource_ignore
=== PAUSE TestAccMetaDefaultTagsDataSource_ignore
=== CONT  TestAccMetaDefaultTagsDataSource_basic
=== CONT  TestAccMetaDefaultTagsDataSource_multiple
=== CONT  TestAccMetaDefaultTagsDataSource_ignore
=== CONT  TestAccMetaDefaultTagsDataSource_empty
--- PASS: TestAccMetaDefaultTagsDataSource_basic (9.45s)
--- PASS: TestAccMetaDefaultTagsDataSource_multiple (9.46s)
--- PASS: TestAccMetaDefaultTagsDataSource_empty (9.55s)
--- PASS: TestAccMetaDefaultTagsDataSource_ignore (18.34s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/meta	22.470s

After applying this configuration

provider "aws" {}

data "aws_default_tags" "test" {}

the Terraform state is

{
  "version": 4,
  "terraform_version": "1.0.9",
  "serial": 1,
  "lineage": "b136bdbf-dd55-0303-c702-7f5a900401d1",
  "outputs": {},
  "resources": [
    {
      "mode": "data",
      "type": "aws_default_tags",
      "name": "test",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "id": "aws",
            "tags": {}
          },
          "sensitive_attributes": []
        }
      ]
    }
  ]
}

which matches the v4.35.0 version.
Unfortunately we can't test state migration as described in Migrating from SDK as the provider configuration has to be explictly defined for default_tags.

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XS Managed by automation to categorize the size of a PR. service/meta labels Oct 21, 2022
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. labels Oct 21, 2022
…PluginSDK_Empty'.

Acceptance test output:

% make testacc TESTARGS='-run=TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK' PKG=meta
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/meta/... -v -count 1 -parallel 20  -run=TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK -timeout 180m
=== RUN   TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty
=== PAUSE TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty
=== CONT  TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty
--- PASS: TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty (48.27s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/meta	52.656s
@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Oct 21, 2022
@jar-b
Copy link
Member

jar-b commented Oct 21, 2022

$ make testacc TESTARGS='-run=TestAccMetaDefaultTagsDataSource_' PKG=meta
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/meta/... -v -count 1 -parallel 20  -run=TestAccMetaDefaultTagsDataSource_ -timeout 180m
=== RUN   TestAccMetaDefaultTagsDataSource_basic
=== PAUSE TestAccMetaDefaultTagsDataSource_basic
=== RUN   TestAccMetaDefaultTagsDataSource_empty
=== PAUSE TestAccMetaDefaultTagsDataSource_empty
=== RUN   TestAccMetaDefaultTagsDataSource_multiple
=== PAUSE TestAccMetaDefaultTagsDataSource_multiple
=== RUN   TestAccMetaDefaultTagsDataSource_ignore
=== PAUSE TestAccMetaDefaultTagsDataSource_ignore
=== RUN   TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty
=== PAUSE TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty
=== CONT  TestAccMetaDefaultTagsDataSource_basic
=== CONT  TestAccMetaDefaultTagsDataSource_ignore
=== CONT  TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty
=== CONT  TestAccMetaDefaultTagsDataSource_multiple
=== CONT  TestAccMetaDefaultTagsDataSource_empty
--- PASS: TestAccMetaDefaultTagsDataSource_multiple (6.15s)
--- PASS: TestAccMetaDefaultTagsDataSource_basic (6.15s)
--- PASS: TestAccMetaDefaultTagsDataSource_empty (10.08s)
--- PASS: TestAccMetaDefaultTagsDataSource_ignore (13.40s)
--- PASS: TestAccMetaDefaultTagsDataSource_MigrateFromPluginSDK_Empty (24.20s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/meta       26.973s

Also verified a local build results in the <v4.35.0 behavior:

$ cat terraform.tfstate
{
  "version": 4,
  "terraform_version": "1.2.9",
  "serial": 3,
  "lineage": "d2c608b8-e9f3-fcf0-e08a-9cdf59522a3f",
  "outputs": {},
  "resources": [
    {
      "mode": "data",
      "type": "aws_default_tags",
      "name": "test",
      "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "id": "aws",
            "tags": {}
          },
          "sensitive_attributes": []
        }
      ]
    }
  ]
}

Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ⚡

@YakDriver YakDriver merged commit 6ef43f2 into main Oct 21, 2022
@YakDriver YakDriver deleted the b-aws_default_tags-null-map branch October 21, 2022 15:46
@github-actions github-actions bot added this to the v4.37.0 milestone Oct 21, 2022
github-actions bot pushed a commit that referenced this pull request Oct 21, 2022
@YakDriver YakDriver modified the milestones: v4.37.0, v4.36.1 Oct 21, 2022
@github-actions
Copy link

This functionality has been released in v4.36.1 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. size/S Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: data "aws_default_tags" "tags" output return null instead empty map cause downstream function error.
3 participants