
Ensure the EC2 instance has the CloudFormation helper scripts installed (aws-cfn-bootstrap), and that its instance profile allows access to any remote resources you reference (for example, S3) as well as CloudFormation APIs if you use cfn-hup.
Example AWS::CloudFormation::Init metadata (YAML)
- cfn-hup is a daemon that polls CloudFormation for metadata changes. When it detects changes, it can invoke configured hooks to re-run cfn-init or other commands to apply updates.
- To use cfn-hup you must:
- Configure its .conf and .hooks files (these are often created by cfn-init).
- Ensure the instance role has permission to call CloudFormation APIs.
- cfn-hup is optional but useful when you want instances to pick up metadata changes without replacing or manually updating instances.
- cfn-init automates instance bootstrapping using AWS::CloudFormation::Init metadata in your CloudFormation template.
- Pair cfn-init with cfn-signal for lifecycle signaling and with cfn-hup for dynamic metadata updates.
- Verify helper scripts (aws-cfn-bootstrap) are installed on your AMI and that IAM permissions for S3 and CloudFormation are in place.
- AWS CloudFormation init (cfn-init)
- cfn-hup daemon
- cfn-signal reference
- CloudFormation helper scripts (aws-cfn-bootstrap)
- Amazon S3 Documentation
- Amazon EC2 Documentation