System Administration & Network Administration
amazon-web-services autoscaling amazon-cloudformation
Updated Fri, 19 Aug 2022 03:31:18 GMT

Bootstrapping in CloudFormation with Autoscale


My CloudFormation template creates an autoscale group and bootstrap it with utility script /opt/aws/bin/cfn-init. When I remove the bootstrap part out of my template the, autoscale get created without any problem, but I add it the CloudFormation Stack fails and add line in /var/log/cloud-init.log :

Error: AutoScalingGroupName does not specify any metadata

The line above appens right after the following command :

/opt/aws/bin/cfn-init --verbose --configsets orderedConfig --region us-east-1 --stack AS15 --resource AutoScalingGroupName --access-key XXXXXXXXXXXXX --secret-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Digging a little bit deeper, in cfn-init I added the following lines the point where it exit:

from pprint import pprint
pprint(vars(detail))

and I get the following trace when running the previous cfn-init command :

{'_description': None,
 '_lastUpdated': datetime.datetime(2012, 7, 12, 14, 52, 42),
 '_logicalResourceId': u'AutoScalingGroupName',
 '_metadata': None,
 '_physicalResourceId': u'AS15-AutoScalingGroupName-HNPOXXXXXXXX',
 '_resourceStatus': u'CREATE_COMPLETE',
 '_resourceStatusReason': None,
 '_resourceType': u'AWS::AutoScaling::AutoScalingGroup',
 '_stackId': u'arn:aws:cloudformation:us-east-1:XXXXXXXXXXXXX:stack/AS15/XXXXXXXX-cc30-11e1-XXXXXX-XXXXXXXXXX',
 '_stackName': u'AS15'}

As you can see, the metadata field is empty and that's the reason why it fails to create the stack. Is there any known side effects for cfn-init when used with autoscale ?




Solution

I just figured it out! The parameter --resource of cfn-init script have to be set with the Launch Configuration name and not the AutoScale Group name. Wish that could help someone :)





Comments (1)