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

Unable to run 0.12upgrade #22020

Closed
hoagsie opened this issue Jul 9, 2019 · 6 comments · Fixed by #22181
Closed

Unable to run 0.12upgrade #22020

hoagsie opened this issue Jul 9, 2019 · 6 comments · Fixed by #22181
Assignees

Comments

@hoagsie
Copy link

hoagsie commented Jul 9, 2019

Terraform Version

0.12.3

Terraform Configuration Files

https://github.com/hoagsie/scratch/blob/master/iamgp.tf.gpg

Crash Output

https://gist.github.com/hoagsie/435026027b568afb036b23cb0e169fbd

Expected Behavior

terraform 0.12upgrade should have completed without error.

Actual Behavior

The error in crash output happens.

Steps to Reproduce

  1. Use terraforming to produce tf files
  2. Execute terraform init in directory
  3. See the upgrade needed message in output
  4. Execute terraform 0.12upgrade

Additional Context

Using terraforming 0.18.0. Latest as of writing.

@mildwonkey
Copy link
Contributor

Hi @hoagsie ,

Thanks for reporting this! I can confirm the crash with the config you've supplied.

Having said that: Can you confirm that the code you attached is the same that you are using locally, and that it works in earlier versions of terraform? I can't run terraform init with 0.11.4:

$ tf version
Terraform v0.11.4
+ provider.aws v2.20.0

[kristin@fairy /tmp/scratch]
$ tf init
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Error loading /tmp/scratch/iamgp.tf: Error reading config for aws_iam_group_policy[DevOps_DevOPS-IAMPolicy]: parse error at 14:45: expected "}" but found ":"

The syntax error tells me that it's not a surprise that it's crashing - terraform 0.12upgrade is only designed to work with valid 0.11 code. Even so, it needs to return an error instead of crashing, and I will take a look!

@mildwonkey
Copy link
Contributor

terraform validate gives more information:

Error: Extra characters after interpolation expression

  on iamgp.tf line 209, in resource "aws_iam_group_policy" "DevOps_DevOPS-IAMPolicy":
 196:
 197:
 198:
 199:
 200:
 201:
 202:
 203:
 204:
 205:
 206:
 207:
 208:
 209:       "Resource": "arn:aws:iam::*:user/${aws:username}"

Expected a closing brace to end the interpolation expression, but found extra
characters.

@mildwonkey
Copy link
Contributor

Modifying ${aws:username} to $${aws:username} fixes the problem - terraform was trying to interpolate ${aws:username} as a terraform variable.

@mildwonkey mildwonkey reopened this Jul 23, 2019
mildwonkey added a commit that referenced this issue Jul 23, 2019
In some cases (see #22020 for a specific example), the parsed hilNode
can be nil. This causes a series of panics. Instead, return an error and
move on.
@hoagsie
Copy link
Author

hoagsie commented Jul 23, 2019

@mildwonkey , no, I haven't tried with other versions of terraform. I'm a newbie to the automated infrastructure world and 0.12 has been my introduction. I was trying to achieve the first goal of getting a map of what I already have in my environment. If it doesn't work with 0.11, I'm curious if this couldn't be a problem with the terraforming tool. Are there any supported solutions for mapping an existing environment into .tf or .tfstate files?

@mildwonkey
Copy link
Contributor

I'm not familiar with the terraforming tool, but if that's what generated your configuration then yes, this is something it could possibly solve by adding a leading $ to things that look like terraform string interpolation ("${}), but are not (such as ${aws:username}).

There are no official solutions for auto-generating configs based on existing resources at this time, sorry!

mildwonkey added a commit that referenced this issue Jul 23, 2019
In some cases (see #22020 for a specific example), the parsed hilNode
can be nil. This causes a series of panics. Instead, return an error and
move on.
@ghost
Copy link

ghost commented Aug 23, 2019

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.

@ghost ghost locked and limited conversation to collaborators Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants