更新时间:2023-09-21 11:23:58
在模板中,为实例userdata使用CloudFormation参数:
Inside your template, use a CloudFormation parameter for the instance userdata:
{
"Parameters": {
"UserData": {
"Type": "String"
}
},
"Resources": {
"Instance": {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"UserData" : { "Ref" : "UserData" },
...
}
},
...
}
}
假设您使用的是类似Unix的命令行环境,请按以下方式创建堆栈:
Assuming you're using a Unix-like command line environment, create your stack like this:
aws cloudformation create-stack --stack-name myStack \
--template-body file://myStack.json \
--parameters ParameterKey=UserData,ParameterValue=$(base64 -w0 userdata.sh)