dtan4 / terraforming

Export existing AWS resources to Terraform style (tf, tfstate) / No longer actively maintained
http://terraforming.dtan4.net/
MIT License
4.3k stars 657 forks source link

Argument names must not be quoted #476

Open heydonovan opened 5 years ago

heydonovan commented 5 years ago

Just needed to grab a security group from our production account:

resource "aws_security_group" "whitelist" {

   ...removed for brevity...

    tags {
        "apps" = "redacted"
        "Name" = "redacted
        "Notes" = "redacted"
    }
}

It looks like terraform fmt complains about the following:

$ terraform version
Terraform v0.12.3

$ terraform fmt

Error: Invalid argument name

  on security_group.tf line 38:
  (source code not available)

Argument names must not be quoted.
jmpsf commented 4 years ago

I had the same problem, the correct tf snippet that worked for me was:

resource "aws_security_group" "whitelist" {

   ...removed for brevity...

    tags = {
        apps = "redacted"
        Name = "redacted
        Notes = "redacted"
    }
}
xlr-8 commented 4 years ago

Actually I think that tags with special characters (. : etc), you need quotes, see the terraform issue. Could you test it please?

earchibald-lv commented 4 years ago

Tags with special characters may need to be quoted, but "normal" tags which are quoted fail the HCL parser:

Error: Invalid argument name

  on main.tf line 79, in resource "aws_vpc" "SpeechIQ-Prod":
  79:         "Name" = "SpeechIQ-Prod"

Argument names must not be quoted.
on3iropolos commented 4 years ago

For clarity, tags need to have the quotes removed after pulling the tf.

on3iropolos commented 4 years ago

Duplicate of #487