I am launching an instance from AWS console from a pre-baked ami, by passing user-data, as
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe \n",
"yum update -y aws-cfn-bootstrap\n",
"yum-config-manager --enable epel\n",
"/opt/aws/bin/cfn-init -v -s ", { "Ref" : "AWS::StackName" }, " -r Ec2Instance ",
" --region ", { "Ref" : "AWS::Region" },
" --configsets ", { "Ref" : "StackType" }, "\n",
"yum-config-manager --disable epel\n",
"sudo initctl stop newrelic-infra\n",
"sudo initctl start newrelic-infra"
]]}}
I tried three things 1. Launched an ec2 with no user data - In this case rc.local is running 2. Launched ec2 with the above user data - In this case rc.local is not running 3. Launched ec2 with the above user data but with /opt/aws/cfn-init command removed - In this case as well rc.local is running
The question is why doesn't it run with /opt/aws/cfn-init and how to fix this.