I have created a cloud formation script
# in mumbai region (working)
Resources:
MyNewEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0fcbc9ed97efe271e
InstanceType: t2.micro
SubnetId: subnet-fc2df495
KeyName: sant-test
UserData:
Fn::Base64:
Fn::Sub: |
#!/bin/bash -xe
yum update -y
echo somenthing:khskhsdh >> test.txt
this is throwing error at echo somenthing:khskhsdh >> test.txt
i get error something like:
How to handle special characters
I looked up all my templates and found an example that works 100%:
Resources:
MyNewEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0fcbc9ed97efe271e
InstanceType: t2.micro
SubnetId: subnet-fc2df495
KeyName: sant-test
UserData:
Fn::Base64: |-
#!/bin/bash
yum update -y
echo somenthing:khskhsdh >> test.txt
The Fn::Sub:
in the question is redundant and causing an error.