Terraform-provider-aws: aws_elasticache_replication_group fails to add, modify, delete tags on existing resource

Created on 7 Sep 2017  ยท  9Comments  ยท  Source: hashicorp/terraform-provider-aws

Terraform Version

Terraform v0.10.3

Affected Resource(s)

AWS Provider

  • aws_elasticache_replication_group

Terraform Configuration Files

 #original
  resource "aws_elasticache_replication_group" "redis" {
      replication_group_id          = "bmcachetest"
      replication_group_description = "${module.tags.name_prefix}cache"
      node_type                     = "${var.node_type}"
      port                          = 6379
      parameter_group_name          = "${aws_elasticache_parameter_group.redis.name}"
      automatic_failover_enabled    = true
      subnet_group_name             = "${var.cache_subnet_group}"
      security_group_ids            = ["${data.aws_security_group.redis_sg.id}"]
      maintenance_window            = "sun:09:00-sun:11:00" # UTC

      cluster_mode {
          replicas_per_node_group     = 1
          num_node_groups             = 2
      }
  }

Original aws_elasticache_replication_group is created without tags with no tags. Resource is then updated with tags.

 # Updated resource
  resource "aws_elasticache_replication_group" "redis" {
      replication_group_id          = "bmcachetest"
      replication_group_description = "${module.tags.name_prefix}cache"
      node_type                     = "${var.node_type}"
      port                          = 6379
      parameter_group_name          = "${aws_elasticache_parameter_group.redis.name}"
      automatic_failover_enabled    = true
      subnet_group_name             = "${var.cache_subnet_group}"
      security_group_ids            = ["${data.aws_security_group.redis_sg.id}"]
      maintenance_window            = "sun:09:00-sun:11:00" # UTC

      cluster_mode {
          replicas_per_node_group     = 1
          num_node_groups             = 2
      }

      tags {
          Owner       = "${module.tags.owner}"
          Service     = "${module.tags.service}"
          Team        = "${module.tags.team}"
          Environment = "${module.tags.environment}"
          Description = "${module.tags.description}"
          Terraform   = "${path.root}"
          autoFailover = "${var.autoFailover}"
          Slack       = "${var.slack_channel}"
      }
  }

Terraform output

aws_elasticache_parameter_group.redis: Refreshing state... (ID: bm-redis-params)
data.aws_security_group.redis_sg: Refreshing state...
aws_elasticache_replication_group.redis: Refreshing state... (ID: bmcachetest)
module.service.aws_elasticache_replication_group.redis: Modifying... (ID: bmcachetest)
  tags.%:            "0" => "8"
  tags.Description:  "" => "userstore cacheops"
  tags.Environment:  "" => "test"
  tags.Owner:        "" => "[email protected]"
  tags.Service:      "" => "userstoreops"
  tags.Slack:        "" => "homerecs-jobs-devs"
  tags.Team:         "" => "ops"
  tags.Terraform:    "" => "/Users/bm/git/terraform-scripts/services/aws/userstore/test"
  tags.autoFailover: "" => "true"

module.service.aws_elasticache_replication_group.redis: Modifications complete after 0s (ID: bmcachetest)

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Expected Behavior

When updating an aws_elasticache_replication_group existing tags or with new tags node associated with replication group will modify, add, or delete.

Actual Behavior

When updating an aws_elasticache_replication_group tags are not updated. Terraform state is updated with new tags however tags are not updated on nodes associated with replication group.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create an aws_elasticache_parameter_group with or without tags
  2. terraform apply
  3. Update aws_elasticache_parameter_group resource with tags.
  4. terraform apply
  5. inspect tags on aws_elasticache_parameter_group

Factoid

Tags are correctly applied only during creation of resource.

bug servicelasticache

Most helpful comment

This bug still exists when I try to update tags for the node of aws_elasticache_replication_group:
apply success, but tags are not updated in AWS:
Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

~ module.redis.aws_elasticache_replication_group.tr-redis-repl
tags.%: "6" => "7"
tags.adsk:moniker: "" => "TR-S-UE1"
tags.adsk:service: "AWS-TR-STAGING" => "AWS-TR-STAGE"

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

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

module.redis.aws_elasticache_replication_group.tr-redis-repl: Modifying... (ID: tr-redis-repl)
tags.%: "6" => "7"
tags.adsk:moniker: "" => "TR-S-UE1"
tags.adsk:service: "AWS-TR-STAGING" => "AWS-TR-STAGE"
module.redis.aws_elasticache_replication_group.tr-redis-repl: Modifications complete after 5s (ID: tr-redis-repl)

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

version info:
C02VVAHYHTD6:stage chenshu$ terraform -version
Terraform v0.11.11

  • provider.aws v1.54.0
  • provider.template v1.0.0

All 9 comments

I'm seeing the same: On replication group creation, tags are applied to all replicas; Changing tags on an existing replication group doesn't work.

Defining replicas using resource "aws_elasticache_cluster" "replica" and assigning tags in that replica's block doesn't change tags on an existing replication group's replicas (even those defined with the replica resource) either.

I can confirm this bug is still present in 1.31.0 :disappointed:

Hey, This bug is still there in Terraform v0.11.8 and provider.aws v1.39.0.

+1

experiencing the same issue with provider.aws v1.40

This bug still exists when I try to update tags for the node of aws_elasticache_replication_group:
apply success, but tags are not updated in AWS:
Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

~ module.redis.aws_elasticache_replication_group.tr-redis-repl
tags.%: "6" => "7"
tags.adsk:moniker: "" => "TR-S-UE1"
tags.adsk:service: "AWS-TR-STAGING" => "AWS-TR-STAGE"

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

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

module.redis.aws_elasticache_replication_group.tr-redis-repl: Modifying... (ID: tr-redis-repl)
tags.%: "6" => "7"
tags.adsk:moniker: "" => "TR-S-UE1"
tags.adsk:service: "AWS-TR-STAGING" => "AWS-TR-STAGE"
module.redis.aws_elasticache_replication_group.tr-redis-repl: Modifications complete after 5s (ID: tr-redis-repl)

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

version info:
C02VVAHYHTD6:stage chenshu$ terraform -version
Terraform v0.11.11

  • provider.aws v1.54.0
  • provider.template v1.0.0

Any progress on this?

Hi @httpstergeek - we've looked into this further, and the ability to modify tags in replication group members is not supported by the AWS API. As a general rule, we are only able to commit to providing functionality in Terraform that maps to what is supported by the underlying APIs, so the ability to modify tags in Terraform isn't something that we plan to add at this point.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gothrek22 picture gothrek22  ยท  3Comments

dvishniakov picture dvishniakov  ยท  3Comments

blaltarriba picture blaltarriba  ยท  3Comments

modax picture modax  ยท  3Comments

hashibot picture hashibot  ยท  3Comments