I keep getting yaml validation errors for a part of my yaml that is not inteded to be yaml, but linux bash script,
(I’m trying to create a CloudFront template to start an EC2 isntance on AWS)
the error message is:
All mapping items must start at the same column at line 14, column 1
and it refers to the -y
after yum update
Resources:
MyInstance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-051f8a213df8bc089
InstanceType: t2.micro
KeyName: mydockertestKP
SecurityGroupIds:
- sg-12345678
UserData:
Fn::Base64:
Fn::Sub |
#!/bin/bash
yum update -y
yum install -y docker
systemctl start docker
curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
anyone knows what can I do to make the aws yaml validator to not treat the bash script as yaml ?
(VS2022 and yamllint.com show the same error)
2
Answers
Looks like I needed to add a
:
after theFn::Sub
The below should fix the issue.