Check Application Package Installation - CloudFormation Template | AWS SysOps Administrator Exam

Check Application Package Installation

Question

You are designing a Cloudformation template to create a set of EC2 Instance and install an application package.

You need to ensure that the stack is only successful if the software package gets installed successfully.

How can you check this?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - A.

The AWS Documentation mentions the following.

The cfn-signal helper script signals AWS CloudFormation to indicate whether Amazon EC2 instances have been successfully created or updated.

If you install and configure software applications on instances, you can signal AWS CloudFormation when those software applications are ready.

Options C and D are incorrect because they cannot signal the completion of the software packages.

Option B is incorrect because this is only used if you need to make changes to the running resources in a stack, you update the stack.

For more information on how cfn signal, please refer to the below URL-

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-signal.html

To ensure that the CloudFormation stack is only considered successful if the software package is installed successfully, you can use the cfn-signal helper script.

Option A - Use the cfn-signal helper script: The cfn-signal helper script is a command that sends a signal to the CloudFormation stack indicating that a particular resource has been successfully created. This signal is then used by CloudFormation to determine whether the creation of the stack should be considered successful or not.

To use the cfn-signal helper script, you need to include the following steps in your CloudFormation template:

  1. Install the cfn-init and cfn-signal packages on your EC2 instances.

  2. Include a metadata section in your CloudFormation template that specifies the installation commands for the software package.

  3. Include a signal resource in your CloudFormation template that specifies the signal URL and the credentials to use when sending the signal.

  4. Include a DependsOn attribute for the signal resource that specifies the resource that needs to be created before the signal can be sent.

When the software package is successfully installed on the EC2 instance, the cfn-signal command sends a success signal to the signal resource. If the software package installation fails, the cfn-signal command sends a failure signal instead. This signal is used by CloudFormation to determine whether the stack creation should be considered successful or not.

Option B - Use the Change sets feature: The Change sets feature allows you to preview the changes that will be made to your stack before they are actually made. While this feature can help you to ensure that your stack is correctly configured before it is created, it cannot be used to verify whether the software package has been successfully installed on the EC2 instances.

Option C - Use Cloudwatch logs to signal the completion: CloudWatch logs can be used to monitor the status of the software package installation on the EC2 instances. However, CloudWatch logs do not provide a way to signal the completion of the installation process to CloudFormation.

Option D - Use Cloudtrail to signal the completion: CloudTrail logs can be used to track the actions taken on your AWS account. While CloudTrail can be used to monitor the software package installation process, it cannot be used to signal the completion of the installation process to CloudFormation.

Therefore, the correct answer is option A - Use the cfn-signal helper script.