我正在尝试通过 aws:runcommand 执行 bash 代码。我已从 AWS Repo 中获取并修改了以下代码段以部署 Golden Image 管道
您在下面看到的内容是通过 CloudFormation 堆栈部署的。形成一个 AWS::SSM::Document 对象,传递各种输入。这是我的自动化文档的主要步骤之一。我正在尝试更新我的实例的操作系统。
{
"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"
]
}
}
}
从系统管理器执行文档后,我通过 SSH 连接到 EC2 实例并尝试echo $http_proxy
,变量未设置,显示代码未启动。
如何运行 bash 代码?