Skip to content

Diff output incorrectly double-quotes map keys on update #30854

@alisdair

Description

@alisdair

Terraform Version

Terraform v1.1.8
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.9.0

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
}

variable "use_tags" {
  default = false
}

locals {
  tags = {
    foo       = "my"
    "bar"     = "test"
    "foo/bar" = "my-test"
  }
}

resource "aws_instance" "web" {
  ami           = "ami-2757f631"
  instance_type = "t2.micro"

  tags = var.use_tags ? local.tags : null
}

Expected Behavior

  # aws_instance.web will be updated in-place
  ~ resource "aws_instance" "web" {
        id                                   = "i-005c16f62aeb7220a"
      ~ tags                                 = {
          + "bar"     = "test"
          + "foo"     = "my"
          + "foo/bar" = "my-test"
        }
      ~ tags_all                             = {
          + "bar"     = "test"
          + "foo"     = "my"
          + "foo/bar" = "my-test"
        }

Actual Behavior

  # aws_instance.web will be updated in-place
  ~ resource "aws_instance" "web" {
        id                                   = "i-005c16f62aeb7220a"
      ~ tags                                 = {
          + "bar"       = "test"
          + "foo"       = "my"
          + "\"foo/bar\"" = "my-test"
        }
      ~ tags_all                             = {
          + "bar"       = "test"
          + "foo"       = "my"
          + "\"foo/bar\"" = "my-test"
        }

Steps to Reproduce

Create a resource with no tags, then plan to add tags:

  1. terraform init
  2. terraform apply -auto-approve3.
  3. terraform plan -var use_tags=true

References

Metadata

Metadata

Assignees

Labels

bugcliconfirmeda Terraform Core team member has reproduced this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions