A developer is writing an AWS CloudFormation template to deploy an Amazon EC2 instance that runs a web server. The developer wants to ensure that the EC2 instance is not marked as CREATE_COMPLETE until the web server application package is successfully installed and the service is started. If the installation fails or does not complete within 15 minutes, the stack creation should fail and rollback. Which TWO actions must the developer perform in the CloudFormation template and instance configuration to meet these requirements?
- Add a CreationPolicy attribute to the EC2 instance resource in the template and set the timeout property to 15 minutes.Answer
- BAdd an UpdatePolicy attribute to the EC2 instance resource in the template to define the wait time for the initial creation signals.
- Execute the cfn-signal helper script in the instance's UserData after the installation and startup commands succeed.Answer
- DRun the cfn-hup daemon inside UserData to monitor the installation logs and automatically trigger stack rollback on failure.
- ERetrieve a signal token by referencing a Systems Manager parameter using a Secrets Manager dynamic reference format in the UserData.
Answer
To meet the requirements, the developer must add a CreationPolicy attribute to the EC2 instance resource with a timeout of 15 minutes, and execute the cfn-signal helper script in the instance's UserData after the installation and startup commands succeed.
The correct actions are adding a CreationPolicy attribute to the EC2 instance resource in the template and executing the cfn-signal helper script in the instance's UserData. The CreationPolicy tells CloudFormation to wait for a signal before marking the instance as successfully created, and the cfn-signal script transmits that signal from the EC2 instance after setup steps finish.
Step-by-Step Solution
Key Concept
AWS CloudFormation CreationPolicy and Helper Scripts
Estimated Time:2m 0s