Can't flip valid YAML
mrichman opened this issue · 4 comments
mrichman commented
I get an error when using this UserData:
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
echo "WaitHandle '${WaitHandle}'"
/bin/echo '%password%' | /bin/passwd cloud_user --stdin
yum update -y
yum install python3 -y
su - cloud_user -c 'aws configure set region us-east-1'
su - cloud_user -c 'python3 -m pip install boto3'
/opt/aws/bin/cfn-signal -e $? -r "UserData script complete" '${WaitHandle}'
Error:
Error: while scanning a simple key
in "<unicode string>", line 129, column 9:
echo "WaitHandle '${WaitHandle}'"
^
could not find expected ':'
in "<unicode string>", line 130, column 9:
yum update -y
koiker commented
I run the sample yaml script and got the same results.
I will troubleshoot that. Probably the the ${placeholder} is being affected by python yaml library
mrichman commented
I got it to work by indenting #!/bin/bash -xe ...
which is not something I've had to do before.
koiker commented
Yep, in this format worked correctly:
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
echo "WaitHandle '${WaitHandle}'"
/bin/echo '%password%' | /bin/passwd cloud_user --stdin
yum update -y
yum install python3 -y
su - cloud_user -c 'aws configure set region us-east-1'
su - cloud_user -c 'python3 -m pip install boto3'
/opt/aws/bin/cfn-signal -e $? -r "UserData script complete" '${WaitHandle}'
mrichman commented
Strange that I've never had to do this indent before, but now that I know the workaround I'm good.