Reputation: 778
I am setting up an EC2 launch template with a user data powershell script and would like to be able to use templatefile in the script itself. I was able to do this with an auto scaling launch configuration because it accepts the user data as a string. With EC2 launch templates it requires it to be a base64encoded string and it did not seem to accept this:
user_data = "${base64encode(<<EOF
<powershell>
$file_content = @"
${templatefile("myfile.txt", var.myfilevars)}
"@
</powershell>
EOF"
)}"
Is there a variation of the above that would work? Or another way to accomplish this?
Upvotes: 1
Views: 5967
Reputation: 86
I think you may have an extra double quote "
, specifically the one right after your EOF
.
Try this:
user_data = "${base64encode(<<EOF
<powershell>
$file_content = @"
${templatefile("myfile.txt", var.myfilevars)}
"@
</powershell>
EOF
)}"
Upvotes: 6