Reputation: 4162
I want to setup an EC2 with ubuntu. After the EC2 is setup a script is run which installs several packages. The log (/var/log/cloud-init-output.log
) show that the script does not error and sends a successful finishing signal.
+ /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: I added some `X, there are real alphanumeric chars in the link.
"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"
}
}
},
What do I need to change in order to get the script passing.
Upvotes: 0
Views: 1352
Reputation: 4162
The problem seems not to appear if aws-cfn-bootstrap
is not installed with "pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
instead I use now easy install
and call the executables directly with e.g. cfn-signal -e 0 -r \"AWS CodeDeploy Agent setup complete.\" '", { "Ref": "WaitHandle" }, "'\n"
Upvotes: 1