A stack is a collection of AWS resources that you create, update, or delete as a single unit using a CloudFormation template.
Click to reveal answer
beginner
What file formats can AWS CloudFormation templates use to create stacks?
AWS CloudFormation templates can be written in JSON or YAML format.
Click to reveal answer
beginner
What is the first step to create a stack in AWS CloudFormation?
The first step is to prepare a CloudFormation template that defines the AWS resources you want to create.
Click to reveal answer
intermediate
How does AWS CloudFormation handle resource creation when you create a stack?
CloudFormation creates all resources defined in the template in the correct order, handling dependencies automatically.
Click to reveal answer
intermediate
What happens if stack creation fails in AWS CloudFormation?
If stack creation fails, CloudFormation rolls back and deletes any resources that were created to keep your environment clean.
Click to reveal answer
Which AWS service is used to create and manage stacks?
AAWS CloudFormation
BAWS EC2
CAWS S3
DAWS Lambda
✗ Incorrect
AWS CloudFormation is the service designed to create and manage stacks of AWS resources.
What file formats are supported for CloudFormation templates?
ACSV and JSON
BXML and JSON
CYAML and XML
DJSON and YAML
✗ Incorrect
CloudFormation templates support JSON and YAML formats.
When creating a stack, what does CloudFormation do if a resource depends on another?
ACreates resources in the correct order automatically
BFails the stack creation
CCreates resources randomly
DRequires manual ordering
✗ Incorrect
CloudFormation automatically handles dependencies and creates resources in the correct order.
If stack creation fails, what is the default behavior of CloudFormation?
ASends an email but keeps resources
BRolls back and deletes created resources
CRetries creation indefinitely
DLeaves partially created resources
✗ Incorrect
CloudFormation rolls back and deletes any resources created during the failed stack creation.
What is the main benefit of using stacks in AWS CloudFormation?
AStore files securely
BRun code without servers
CManage multiple resources as a single unit
DMonitor network traffic
✗ Incorrect
Stacks allow you to manage multiple AWS resources together as one unit.
Explain the process of creating a stack in AWS CloudFormation from start to finish.
Think about the steps you take from writing the template to the stack being ready.
You got /5 concepts.
Describe what happens if a resource fails to create during stack creation.
Consider how CloudFormation keeps your environment clean.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of creating a stack in AWS CloudFormation?
easy
A. To group related cloud resources for easy management
B. To write code for AWS Lambda functions
C. To monitor AWS billing and usage
D. To create user accounts in AWS IAM
Solution
Step 1: Understand what a stack represents
A stack is a collection of AWS resources that you manage as a single unit.
Step 2: Identify the purpose of grouping resources
Grouping resources simplifies deployment, updates, and deletion.
Final Answer:
To group related cloud resources for easy management -> Option A
Quick Check:
Stack = Group resources [OK]
Hint: Stacks group resources to manage them together [OK]
Common Mistakes:
Confusing stacks with user accounts
Thinking stacks are for billing
Mixing stacks with Lambda code writing
2. Which AWS CLI command is used to create a stack from a template file named template.yaml?
easy
A. aws s3 create-bucket --template template.yaml
B. aws cloudformation create-stack --stack-name MyStack --template-body file://template.yaml
C. aws cloudformation deploy --stack-name MyStack --template-file file://template.yaml
D. aws ec2 create-stack --template-file template.yaml
Solution
Step 1: Identify the correct AWS service and command
Creating stacks uses the AWS CloudFormation service and the command is create-stack.
Step 2: Check the correct syntax for template file input
The template file is specified with --template-body file://filename.
Final Answer:
aws cloudformation create-stack --stack-name MyStack --template-body file://template.yaml -> Option B
Quick Check:
Use create-stack with --template-body file:// [OK]
Hint: Use create-stack with --template-body file:// [OK]
Common Mistakes:
Using wrong AWS service like EC2 or S3
Using --template-file instead of --template-body
Confusing create-stack with deploy command
3. Given this AWS CLI command: aws cloudformation create-stack --stack-name TestStack --template-body file://template.yaml --parameters ParameterKey=Env,ParameterValue=prod What will happen when this command runs?
medium
A. The command will fail because parameters must be in JSON format
B. The stack will be created with default parameter values ignoring Env
C. The stack will be created but the Env parameter will be ignored
D. A stack named TestStack is created using the template with Env parameter set to prod
Solution
Step 1: Understand parameter usage in create-stack command
The --parameters option allows passing key-value pairs to customize the stack.
Step 2: Check the syntax correctness
The syntax ParameterKey=Env,ParameterValue=prod is valid for AWS CLI parameters.
Final Answer:
A stack named TestStack is created using the template with Env parameter set to prod -> Option D
Quick Check:
Parameters customize stack creation [OK]
Hint: Parameters use ParameterKey= and ParameterValue= pairs [OK]
Common Mistakes:
Thinking parameters must be JSON
Assuming parameters are ignored if passed
Confusing parameter syntax with other commands
4. You run this command to create a stack: aws cloudformation create-stack --stack-name MyStack --template-body file://template.yaml But you get an error: Template format error: YAML not well-formed. What is the most likely cause?
medium
A. The template.yaml file has syntax errors in YAML formatting
B. The stack name MyStack is invalid
C. The AWS CLI command is missing the region parameter
D. The template file path is incorrect
Solution
Step 1: Analyze the error message
The error says "YAML not well-formed" which means the template file has syntax issues.
Step 2: Check other possible causes
Stack name and region issues cause different errors; file path errors cause file not found errors.
Final Answer:
The template.yaml file has syntax errors in YAML formatting -> Option A
Quick Check:
YAML errors cause template format error [OK]
Hint: Check YAML syntax carefully for formatting errors [OK]
Common Mistakes:
Assuming stack name causes YAML errors
Ignoring file path correctness
Forgetting to check template syntax
5. You want to create a stack that launches an EC2 instance with a parameter to choose the instance type. Your template uses a parameter named InstanceType. Which AWS CLI command correctly creates the stack with t3.micro as the instance type?
hard
A. aws cloudformation deploy --stack-name EC2Stack --template-file file://ec2.yaml --parameter-overrides InstanceType=t3.micro
B. aws cloudformation create-stack --stack-name EC2Stack --template-body file://ec2.yaml --parameters InstanceType=t3.micro
C. aws cloudformation create-stack --stack-name EC2Stack --template-body file://ec2.yaml --parameters ParameterKey=InstanceType,ParameterValue=t3.micro
D. aws ec2 run-instances --instance-type t3.micro --template-file ec2.yaml
Solution
Step 1: Identify the correct command and syntax for stack creation with parameters
The create-stack command uses --parameters ParameterKey=key,ParameterValue=value syntax.
Step 2: Verify the parameter key and value match the template
The parameter key is InstanceType and value is t3.micro, correctly formatted in aws cloudformation create-stack --stack-name EC2Stack --template-body file://ec2.yaml --parameters ParameterKey=InstanceType,ParameterValue=t3.micro.