Terraform: Argument names must not be quoted, but throws an error when unquoted

Created on 16 Jul 2019  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version

$ terraform version
Terraform v0.12.4

Expected Behavior

I should be able to use the fixed tag ignoring functionality introduced by #21788 and this comment https://github.com/hashicorp/terraform/issues/21444#issuecomment-504026691

Actual Behavior

resource "aws_vpc" "ct" {
  cidr_block                       = "${var.vpc_cidr_ipv4}"
  assign_generated_ipv6_cidr_block = "true"
  instance_tenancy                 = "default"
  enable_dns_support               = true
  enable_dns_hostnames             = true

  tags {
    Name       = "${var.infra_name}_${replace(var.region,"-","")}"
    TERRAFORM  = "true"
    INFRA_NAME = "${var.infra_name}"
    "kubernetes.io" = "unset"
  }

  lifecycle {
    create_before_destroy = true
    ignore_changes        = [
      tags["kubernetes.io"]
    ]
  }
}
On modules/vpc/vpc.tf line 12: Argument names must not be quoted.

Changing the resource to the following snippet where I unquote the kubernetes.io argument throws a different error.

resource "aws_vpc" "ct" {
  cidr_block                       = "${var.vpc_cidr_ipv4}"
  assign_generated_ipv6_cidr_block = "true"
  instance_tenancy                 = "default"
  enable_dns_support               = true
  enable_dns_hostnames             = true

  tags {
    Name       = "${var.infra_name}_${replace(var.region,"-","")}"
    TERRAFORM  = "true"
    INFRA_NAME = "${var.infra_name}"
    kubernetes.io = "unset"
  }

  lifecycle {
    create_before_destroy = true
    ignore_changes        = [
      tags["kubernetes.io"]
    ]
  }
}
Error: Argument or block definition required

On modules/vpc/vpc.tf line 12: An argument or block definition is required
here. To set an argument, use the equals sign "=" to introduce the argument
value.

I'm not sure how to proceed here.

Steps to Reproduce

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

  1. terraform init
  2. terraform plan

References

  • #21788
  • #21444

Most helpful comment

Disregard, this was an issue during my upgrade from 0.11.14 to 0.12.4 where the tags { block should have been tags = {

All 3 comments

If I remove "kubernetes.io" = "unset"/kubernetes.io = "unset" from the tags block, then terraform progresses.

Disregard, this was an issue during my upgrade from 0.11.14 to 0.12.4 where the tags { block should have been tags = {

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.

Was this page helpful?
0 / 5 - 0 ratings