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

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

Closed
alisdair opened this issue Apr 13, 2022 · 2 comments · Fixed by #30855
Closed

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

alisdair opened this issue Apr 13, 2022 · 2 comments · Fixed by #30855
Assignees
Labels
bug cli confirmed a Terraform Core team member has reproduced this issue v1.1 Issues (primarily bugs) reported against v1.1 releases

Comments

@alisdair
Copy link
Member

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

@alisdair alisdair added bug new new issue not yet triaged labels Apr 13, 2022
@alisdair alisdair added cli confirmed a Terraform Core team member has reproduced this issue v1.1 Issues (primarily bugs) reported against v1.1 releases and removed new new issue not yet triaged labels Apr 13, 2022
@stevehipwell
Copy link

Thanks for the quick follow up and opening of the issue @alisdair!

@github-actions
Copy link

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 have found a problem that seems similar to this, 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 May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug cli confirmed a Terraform Core team member has reproduced this issue v1.1 Issues (primarily bugs) reported against v1.1 releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants