ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 370 - SOA-C02 discussion

Report
Export

A company has created an AWS CloudFormation template that consists of the AWS: EC2 Instance resource and a custom Cloud Formation resource The custom CloudFormation resource is an AWS Lambda function that attempts to run automation on the Amazon EC2 instance.

During testing, the Lambda function fails because the Lambda function tries to run before the EC2 instance is launched

Which solution will resolve this issue?

A.
Add a DependsOn attribute to the custom resource. Specify the EC2 instance in the DependsOn attribute.
Answers
A.
Add a DependsOn attribute to the custom resource. Specify the EC2 instance in the DependsOn attribute.
B.
Update the custom resource's service token to point to a valid Lambda function
Answers
B.
Update the custom resource's service token to point to a valid Lambda function
C.
Update the Lambda function to use the cfn-response module to send a response to the custom resource.
Answers
C.
Update the Lambda function to use the cfn-response module to send a response to the custom resource.
D.
Use the Fn::lf intrinsic function to check for the EC2 instance before the custom resource runs.
Answers
D.
Use the Fn::lf intrinsic function to check for the EC2 instance before the custom resource runs.
Suggested answer: A

Explanation:

DependsOn Attribute in CloudFormation:

The DependsOn attribute in AWS CloudFormation ensures that one resource is created only after another resource has been successfully created. In this case, it ensures that the EC2 instance is fully launched before the custom resource (the Lambda function) is executed.

Steps:

Update the CloudFormation template to include the DependsOn attribute for the custom resource.

Ensure that the custom resource references the EC2 instance.

Resources:

MyEC2Instance:

Type: AWS::EC2::Instance

Properties:

# EC2 properties

MyCustomResource:

Type: Custom::MyCustomResource

DependsOn: MyEC2Instance

Properties:

ServiceToken: !GetAtt MyLambdaFunction.Arn

# Other properties

asked 16/09/2024
tirou RANGA
34 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first