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

file function argument interpolation error #213

Closed
buth opened this issue Aug 21, 2014 · 13 comments
Closed

file function argument interpolation error #213

buth opened this issue Aug 21, 2014 · 13 comments
Labels

Comments

@buth
Copy link
Contributor

buth commented Aug 21, 2014

I'm attempting to load the value of the user_data attribute of an AWS instance resource from a local file. I've run into some strange behavior regarding the argument passed to the file function.

user_data = "${file("user-data/ssh-gateway.yml")}"

... throws a syntax error.

user_data = "${file(\"user-data/ssh-gateway.yml\")}"

... also throws a syntax error.

user_data = "${file('user-data/ssh-gateway.yml')}"

... sets the user data to the uninterpolated string, ${file('user-data/ssh-gateway.yml')}.

user_data = "${file(user-data/ssh-gateway.yml)}"

... sets the user data to the uninterpolated string, ${file(user-data/ssh-gateway.yml)}.

@mitchellh mitchellh added the bug label Aug 21, 2014
@mitchellh
Copy link
Contributor

Interesting, I'm not sure yet where this is happening but its certainly a bug somewhere. Tagged.

@buth
Copy link
Contributor Author

buth commented Aug 21, 2014

Which syntax should be correct?

@mitchellh
Copy link
Contributor

The first/top one should work. The rest should be invalid.

@mitchellh
Copy link
Contributor

Fixed: 4a3dff2

@buth
Copy link
Contributor Author

buth commented Aug 21, 2014

I'm still actually getting a syntax error with the top entry. Seems to happen regardless of whether or not the path is valid, points to an empty file, contains sub-directories, etc. The error also seems mention the wrong line number.

@mitchellh
Copy link
Contributor

Are you sure you compiled with my fix? I just used it in a real TF file without isuse.

@buth
Copy link
Contributor Author

buth commented Aug 21, 2014

I'm using the master branch at 5b620b7 and still having the issue. It's reporting:

Error loading config: Error parsing 50-ssh-gateway.tf: Line 22, column 1: syntax error

Oddly, there is no line 22 in that file. If I remove this statement:

user_data = "${file("user-data/ssh-gateway.yml")}"

It works.

@buth
Copy link
Contributor Author

buth commented Aug 21, 2014

Of note, in just HCL, attempting to decode this line:

foo = "${func("foo/bar")}"

Results in a syntax error as well. Perhaps it's something lower level than Terraform? Thanks for your help with this!

@mitchellh
Copy link
Contributor

That could be possible, let me see.

@mitchellh
Copy link
Contributor

Ah you're right, I was testing with a bad branch. Errr. I know whats going on here.

@mitchellh mitchellh reopened this Aug 21, 2014
@mitchellh
Copy link
Contributor

Fixed upstream, please try again!

@ghost
Copy link

ghost commented Mar 1, 2016

how to use user_data in terraform :
I ahve to pass clustername , number of nodes etc. in the user data

@ghost
Copy link

ghost commented Apr 27, 2020

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 Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants