I'm trying to execute bash code via aws:runcommand. I have taken and adapted the below snippet from the AWS Repo to deploy a Golden Image pipeline
What you see below is deployed via a CloudFormation Stack. An AWS::SSM::Document object is formed, passing various inputs. This is one of the mainSteps of my automation document. I'm trying to update the OS of my instance.
{
"name": "updateOSSoftware",
"action": "aws:runCommand",
"maxAttempts": 3,
"timeoutSeconds": 3600,
"onFailure": "Abort",
"inputs": {
"DocumentName": "AWS-RunShellScript",
"InstanceIds": [
"{{startInstances.InstanceIds}}"
],
"Parameters": {
"commands": [
"export https_proxy=http://myproxy.com:myport",
"export https_proxy='{{OutBoundProxy}}'",
"set -e",
"[ -x \"$(which wget)\" ] && get_contents='wget $1 -O -'",
"[ -x \"$(which curl)\" ] && get_contents='curl -s -f $1'",
"eval $get_contents https://aws-ssm-downloads-eu-west-1.s3.amazonaws.com/scripts/aws-update-linux-instance > /tmp/aws-update-linux-instance",
"chmod +x /tmp/aws-update-linux-instance",
"/tmp/aws-update-linux-instance --pre-update-script '{{PreUpdateScript}}' --post-update-script '{{PostUpdateScript}}' --include-packages '{{IncludePackages}}' --exclude-packages '{{ExcludePackages}}' 2>&1 | tee /tmp/aws-update-linux-instance.log"
]
}
}
}
Once I execute the document from the Systems Manger, I SSH into the EC2 instance and trying and echo $http_proxy, the variable is unset, showing the code wasn't launched.
How can I run bash code?
aws:createimage