我想用ubuntu设置EC2。设置EC2后,将运行一个安装多个软件包的脚本。日志(/var/log/cloud-init-output.log
)显示脚本没有错误并发送成功的结束信号。
+ /usr/local/bin/cfn-signal -e 0 -r 'AWS CodeDeploy Agent setup complete.' 'https://cloudformation-waitcondition-eu-central-1.s3.eu-central-1.amazonaws.com/arn%3Aaws%3Acloudformation%3Aeu-central-1%XXXXXXXXX%3Astack/XXXXXXXXXX/XXXXXXXX-XXXX-11e6-9ec8-50a68ad4f262/WaitHandle?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20160608T172814Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86399&X-Amz-Credential=XXXXXXXXXXXXXX%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Signature=XXXXXXXXXXXXXXX'
/usr/local/lib/python2.7/dist-packages/cfnbootstrap/packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
CloudFormation signaled successfully with SUCCESS.
Cloud-init v. 0.7.5 finished at Wed, 08 Jun 2016 17:34:00 +0000. Datasource DataSourceEc2. Up 99.87 seconds
PS:我添加了一些`X,链接中有真正的字母数字字符。
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash -ex\n",
"apt-get update\n",
"apt-get -y install python-pip\n",
"apt-get -y install python-setuptools\n",
"apt-get -y install ruby2.0\n",
"apt-get install -y awscli\n",
"pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"# Helper function.\n",
"function error_exit\n",
"{\n",
"/usr/local/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref": "WaitHandle" }, "'\n",
"exit 1\n",
"}\n",
"#Install nodejs, npm\n",
"curl -sL https://deb.nodesource.com/setup_6.x\n",
"apt-get install -y nodejs npm || error_exit 'Failed to install nodejs.'\n",
"npm install pm2 -g || error_exit 'Failed to install pm2.'\n",
"# Install the AWS CodeDeploy Agent.\n",
"cd /home/ubuntu/\n",
"aws s3 --region eu-west-1 cp 's3://aws-codedeploy-eu-west-1/latest/install' . || error_exit 'Failed to download AWS CodeDeploy Agent.'\n",
"chmod +x ./install\n",
"./install auto\n",
"/usr/local/bin/cfn-init --stack ", { "Ref":"AWS::StackId" }, " --resource LinuxEC2Instance", " --region ", { "Ref": "AWS::Region" }, "\n",
"# All is well, so signal success.\n",
"/usr/local/bin/cfn-signal -e 0 -r \"AWS CodeDeploy Agent setup complete.\" '", { "Ref": "WaitHandle" }, "'\n"
]
]
}
},
"WaitHandle": {
"Type": "AWS::CloudFormation::WaitConditionHandle",
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "761ddc9a-7c3b-41ca-9fa1-21429046b271"
}
}
},
"WaitCondition": {
"Type": "AWS::CloudFormation::WaitCondition",
"Properties": {
"Count": {
"Ref": "InstanceCount"
},
"Handle": {
"Ref": "WaitHandle"
},
"Timeout": "300"
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "a2c91b03-2c8c-4bd5-9c44-efdb89cf5375"
}
}
},
为了让脚本通过,我需要更改什么。
答案 0 :(得分:1)
如果aws-cfn-bootstrap
未与"pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
一起安装,而我现在使用easy install
并直接使用例如cfn-signal -e 0 -r \"AWS CodeDeploy Agent setup complete.\" '", { "Ref": "WaitHandle" }, "'\n"
调用可执行文件,则似乎不会出现问题abc.def.com:8080