DevOps Engineering on AWS Certification Infrastructure as Code with CloudFormation and CDK 1 — Questions and Answers
Question 1: Which CloudFormation resource property allows you to specify that a resource must be created before another resource?
- DependsOn (Correct answer)
- Metadata
- DeletionPolicy
- UpdatePolicy
Correct answer: DependsOn
The DependsOn attribute ensures CloudFormation creates the specified resource before the resource that contains the DependsOn property.
Question 2: What CloudFormation policy prevents a resource from being deleted when the stack is deleted?
- UpdateReplacePolicy
- DependsOn
- DeletionPolicy: Retain (Correct answer)
- CreationPolicy
Correct answer: DeletionPolicy: Retain
Setting DeletionPolicy to Retain preserves the resource after the CloudFormation stack is deleted.
Question 3: Which AWS CDK construct level represents a single AWS resource with sensible defaults?
- L1 (CfnResource)
- L2 (Resource) (Correct answer)
- L3 (Pattern)
- L4 (Library)
Correct answer: L2 (Resource)
L2 constructs are curated AWS resource constructs with sensible defaults that abstract CloudFormation resource properties.
Question 4: What CloudFormation function retrieves the value of a parameter or resource output from the same template?
- Fn::Sub
- Fn::ImportValue
- Ref (Correct answer)
- Fn::GetAtt
Correct answer: Ref
The Ref function returns the value of a parameter or the default attribute of a resource defined in the same CloudFormation template.
Question 5: In AWS CDK, which command synthesizes the CDK app into CloudFormation templates?
- cdk deploy
- cdk diff
- cdk synth (Correct answer)
- cdk bootstrap
Correct answer: cdk synth
The cdk synth command synthesizes your CDK application and outputs the equivalent CloudFormation templates.
Question 6: Which CloudFormation feature allows you to share output values from one stack with another stack in the same account and region?
- Stack policies
- Cross-stack references using Exports and Fn::ImportValue (Correct answer)
- CloudFormation StackSets
- Nested stacks
Correct answer: Cross-stack references using Exports and Fn::ImportValue
Cross-stack references use Outputs with Export names in one stack and Fn::ImportValue in another stack to share values within the same region.
Which CloudFormation resource property allows you to specify that a resource must be created before another resource?