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

Escaping Remote ENV in Interpolation #1098

Closed
delianides opened this Issue Mar 2, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@delianides

delianides commented Mar 2, 2015

When using systemd on CoreOS, consider the following:

   - name: docker.service
      command: start
      content: |
        [Unit]
        After=flannel.service
        Wants=flannel.service
        Description=Docker Application Container Engine
        Documentation=http://docs.docker.io

        [Service]
        EnvironmentFile=/run/flannel/subnet.env
        ExecStartPre=/bin/mount --make-rprivate /
        ExecStart=/usr/bin/docker -d --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} -s=overlay -H fd://

        [Install]
        WantedBy=multi-user.target

If I place this in a heredoc (hashicorp/hcl#6) it fails because terraform tries to interpolate the FLANNEL environment variables. Is there anyway to escape those so terraform doesn't try to expand them?

@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Mar 2, 2015

Member

Use a second dollar sign: $${FLANNEL_SUBNET}.

Member

mitchellh commented Mar 2, 2015

Use a second dollar sign: $${FLANNEL_SUBNET}.

@mitchellh mitchellh closed this Mar 2, 2015

@bitglue

This comment has been minimized.

Show comment
Hide comment
@bitglue

bitglue Apr 7, 2015

Maybe this could be documented somewhere? I don't see it in the configuration syntax or the interpolation syntax.

But also, it doesn't seem to work. While it does avoid the syntax error due to the invalid interpolation, it also puts a literal $$ in the resulting parsed string.

bitglue commented Apr 7, 2015

Maybe this could be documented somewhere? I don't see it in the configuration syntax or the interpolation syntax.

But also, it doesn't seem to work. While it does avoid the syntax error due to the invalid interpolation, it also puts a literal $$ in the resulting parsed string.

@bentterp

This comment has been minimized.

Show comment
Hide comment
@bentterp

bentterp Aug 26, 2015

I ran into the same issue with an AWS policy as a heredoc as per the documentation:

policy = <<EOF

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:_LoginProfile",
"iam:_AccessKey",
"iam:AccessKey"
],
"Resource": "arn:aws:iam::564070118781:user/$${aws:username}"
},

This results in the policydocument on AWS having double $'s - which of course doesn't work
Using single $ makes terraform try to interpolate, and fail

bentterp commented Aug 26, 2015

I ran into the same issue with an AWS policy as a heredoc as per the documentation:

policy = <<EOF

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:_LoginProfile",
"iam:_AccessKey",
"iam:AccessKey"
],
"Resource": "arn:aws:iam::564070118781:user/$${aws:username}"
},

This results in the policydocument on AWS having double $'s - which of course doesn't work
Using single $ makes terraform try to interpolate, and fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment