0
我有以下CloudFormation腳本,它可以正確設置所有基礎結構。當我從CloudFormation收到CREATE_COMPLETE消息時,可以通過SSH訪問EC2,但應用程序尚未安裝。如果我等3分鐘,他們就會出現。CloudFormation模板安裝但沒有指示腳本何時結束
有什麼辦法可以讓CloudFormation等到所有元數據安裝好(git和htop)?
以下腳本:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "My first CloudFormation template",
"Resources": {
"WebServerInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-abeb9e91",
"InstanceType": "t2.micro",
"KeyName": "test-key-pair",
"SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ],
"UserData": {
"Fn::Base64": { "Fn::Join":["", [
"#!/bin/bash -ex\n",
"apt-get update\n",
"apt-get -y install python-setuptools\n",
"mkdir aws-cfn-bootstrap-latest\n",
"curl https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz | tar xz -C aws-cfn-bootstrap-latest --strip-components 1\n",
"easy_install aws-cfn-bootstrap-latest\n",
"sudo /usr/local/bin/cfn-init --stack ", { "Ref":"AWS::StackName" }, " --resource WebServerInstance", " --region ", { "Ref": "AWS::Region" }, "\n",
"\n",
"/usr/local/bin/cfn-signal --exit-code $?"
]]}
}
},
"Metadata": {
"AWS::CloudFormation::Init": {
"config": {
"packages": {
"apt": {
"htop": [],
"git": []
}
}
}
}
}
}
}
}
太棒了,就是我在找的東西!感謝你! – AdrianGW 2015-03-19 12:22:56