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

resource/elasticache_subnet_group: appropriately ignore default tags configuration in default resource #19267

Merged
merged 1 commit into from
May 19, 2021

Conversation

anGie44
Copy link
Contributor

@anGie44 anGie44 commented May 6, 2021

Community Note

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

Closes #19213

Notes

  • Code change following a viable workaround which is to ignore_changes to tags_all (on pre-existing resources)
  • Testing the "default" subnet group I believe requires importing, trying to create a new one in a test returns
"│ Error: error creating ElastiCache Subnet Group (default): InvalidParameterValue: The value for parameter CacheSubnetGroupName is not a valid identifier. The identifier default is reserved."

Using the following config with reference to the default ElastiCacheSubnetGroup in us-west-2:

provider "aws" {
  default_tags {
    tags = {
      Name = "terraform-default"
    }
  }
}

resource "aws_elasticache_subnet_group" "default" {
  name        = "default"
  description = "Default CacheSubnetGroup"
  subnet_ids  = data.aws_subnet_ids.test.ids
}

data "aws_subnet_ids" "test" {
  vpc_id = "XXXXXXX"
}

With v3.38.0 of the provider, Terraform plan after import returns:

aws_elasticache_subnet_group.default: Refreshing state... [id=default]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_elasticache_subnet_group.default will be updated in-place
  ~ resource "aws_elasticache_subnet_group" "default" {
        id          = "default"
        name        = "default"
        tags        = {}
      ~ tags_all    = {
          + "Name" = "terraform-default"
        }
        # (3 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

With provider built from this branch, Terraform plan after import returns:

aws_elasticache_subnet_group.default: Refreshing state... [id=default]

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your configuration and the remote system(s). As a result, there are no actions to take.

Output from acceptance testing:


ok  	github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags	0.755s

--- PASS: TestAccAWSElasticacheSubnetGroup_basic (27.39s)
--- PASS: TestAccAWSElasticacheSubnetGroup_update (50.82s)
--- PASS: TestAccAWSElasticacheSubnetGroup_tags (64.58s)

@ghost ghost added size/M Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. service/elasticache Issues and PRs that pertain to the elasticache service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels May 6, 2021
@anGie44 anGie44 force-pushed the b-elasticache-subnet-group-default-tags branch from c9f26a9 to 7d350f8 Compare May 6, 2021 18:18
@anGie44 anGie44 marked this pull request as ready for review May 6, 2021 18:19
@anGie44 anGie44 requested a review from a team as a code owner May 6, 2021 18:19
@anGie44 anGie44 added the bug Addresses a defect in current functionality. label May 6, 2021
@anGie44 anGie44 changed the title resource/elasticache_subnet_group: appropriately handle default tags support in default resource resource/elasticache_subnet_group: appropriately ignore default tags configuration in default resource May 6, 2021
@ewbankkit ewbankkit self-assigned this May 14, 2021
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% terraform init

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 3.40.0...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.aws: version = "~> 3.40"

Terraform has been successfully initialized!

% terraform import aws_elasticache_subnet_group.default default
aws_elasticache_subnet_group.default: Importing from ID "default"...
aws_elasticache_subnet_group.default: Import prepared!
  Prepared aws_elasticache_subnet_group for import
aws_elasticache_subnet_group.default: Refreshing state... [id=default]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

% terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_subnet_ids.test: Refreshing state...
aws_elasticache_subnet_group.default: Refreshing state... [id=default]

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_elasticache_subnet_group.default will be updated in-place
  ~ resource "aws_elasticache_subnet_group" "default" {
        arn         = "arn:aws:elasticache:us-west-2:123456789012:subnetgroup:default"
        description = "Default CacheSubnetGroup"
        id          = "default"
        name        = "default"
        subnet_ids  = [
            "subnet-xxxxxxxxxxxxxxxxx",
            "subnet-xxxxxxxxxxxxxxxxx",
            "subnet-xxxxxxxxxxxxxxxxx",
            "subnet-xxxxxxxxxxxxxxxxx",
        ]
        tags        = {}
      ~ tags_all    = {
          + "Name" = "terraform-default"
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

% terraform apply

aws_elasticache_subnet_group.default: Modifying... [id=default]

Error: error updating tags: error tagging resource (arn:aws:elasticache:us-west-2:123456789012:subnetgroup:default): InvalidParameterValue: Tagging on default resources is not supported
	status code: 400, request id: 1ae50517-5045-46e5-8765-216055db901a

  on main.tf line 11, in resource "aws_elasticache_subnet_group" "default":
  11: resource "aws_elasticache_subnet_group" "default" {

% terraform init --plugin-dir=$HOME/go/bin

Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

% terraform plan                          
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.aws_subnet_ids.test: Refreshing state...
aws_elasticache_subnet_group.default: Refreshing state... [id=default]

------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

@ewbankkit ewbankkit removed their assignment May 17, 2021
@anGie44 anGie44 added this to the v3.42.0 milestone May 19, 2021
@anGie44 anGie44 merged commit c923fc3 into main May 19, 2021
@anGie44 anGie44 deleted the b-elasticache-subnet-group-default-tags branch May 19, 2021 16:33
github-actions bot pushed a commit that referenced this pull request May 19, 2021
@ghost
Copy link

ghost commented May 20, 2021

This has been released in version 3.42.0 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 for triage. Thanks!

@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 Jun 19, 2021
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. provider Pertains to the provider itself, rather than any interaction with AWS. service/elasticache Issues and PRs that pertain to the elasticache service. size/M 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.

Tagging on default resources not supported aws_elasticache_subnet_group
2 participants