Skip to main content

Validation Quiz - MODULE 15

This 30-question quiz allows you to validate your knowledge on CloudFormation and Infrastructure as Code.


Question 1​

What is Infrastructure as Code (IaC)?

A) Code that runs on the infrastructure
B) Managing infrastructure via declarative configuration files
C) A programming language
D) An AWS service

See the answer

Answer: B

IaC involves defining and managing infrastructure through code/configuration files rather than manually. Advantages: reproducibility, versioning, automation, consistency, living documentation.


Question 2​

What is AWS CloudFormation?

A) A weather service
B) AWS's Infrastructure as Code service for provisioning resources via templates
C) A storage service
D) A Load Balancer

See the answer

Answer: B

CloudFormation allows defining AWS resources in templates (YAML or JSON). It creates, updates, and deletes resources automatically by managing dependencies.


Question 3​

What file formats does CloudFormation support?

A) XML only
B) JSON and YAML
C) Python only
D) Terraform

See the answer

Answer: B

CloudFormation supports JSON and YAML. YAML is generally preferred for readability (supports comments, less verbose). Both are functionally equivalent.


Question 4​

What is a CloudFormation "Stack"?

A) A stack of servers
B) A set of AWS resources managed as a unit from a template
C) A type of storage
D) A security group

See the answer

Answer: B

A Stack is a collection of AWS resources created and managed together. When you create a stack, CloudFormation provisions all resources defined in the template. Deleting the stack deletes all its resources.


Question 5​

What are the main sections of a CloudFormation template?

A) Only Resources
B) Parameters, Mappings, Conditions, Resources, Outputs
C) Only Inputs and Outputs
D) Variables and Functions

See the answer

Answer: B

Sections: AWSTemplateFormatVersion, Description, Metadata, Parameters (inputs), Mappings, Conditions, Transform, Resources (mandatory), Outputs. Only Resources is mandatory.


Question 6​

What is the only mandatory section of a CloudFormation template?

A) Parameters
B) Resources
C) Outputs
D) Description

See the answer

Answer: B

The Resources section is the only mandatory one. It defines the AWS resources to be created (EC2, S3, VPC, etc.). Without resources, the template creates nothing.


Question 7​

What is a "Parameter" in CloudFormation?

A) A constant
B) A value provided at stack creation/update time
C) A resource
D) An output

See the answer

Answer: B

Parameters are customizable input values during deployment. They make templates reusable (e.g., choose instance type, environment name). Default values and constraints can be defined.


Question 8​

How to reference a parameter in a CloudFormation template?

A) Dollar-brace syntax
B) !Ref ParameterName
C) @Parameter
D) #Ref Parameter

See the answer

Answer: B

The intrinsic function !Ref returns the value of a parameter or the ID of a resource. YAML syntax: !Ref ParameterName. JSON syntax: Ref with ParameterName in quotes.


Question 9​

What is an "Output" in CloudFormation?

A) An output file
B) A value exported from the stack (e.g., URL, ID) usable by other stacks
C) A log
D) An error

See the answer

Answer: B

Outputs export values after stack creation: resource IDs, URLs, ARNs. They can be displayed in the console, returned by the API, or imported into other stacks (cross-stack references).


Question 10​

How to import a value from another stack?

A) !Import
B) !ImportValue ExportName
C) !CrossStack
D) It's not possible

See the answer

Answer: B

!ImportValue allows importing a value exported by another stack. The source stack must have an Output with Export:Name. The importing stack uses !ImportValue ExportName to retrieve the value.


Question 11​

What is the !GetAtt function?

A) Get an attribute
B) Retrieve a specific attribute of a resource (e.g., ARN, DNS name)
C) Get all attributes
D) Delete an attribute

See the answer

Answer: B

!GetAtt returns a specific attribute of a resource. Example: !GetAtt MyEC2.PublicIp returns the public IP. Each resource type has different attributes documented in the CloudFormation reference.


Question 12​

What does the !Sub function do?

A) Subtraction
B) Variable substitution in a string
C) Subroutine
D) Subscription

See the answer

Answer: B

!Sub substitutes variables in a string. Example: !Sub with arn:aws:s3:::BucketName/* replaces the variable with the value. Supports template variables and pseudo-parameters.


Question 13​

What is a pseudo-parameter in CloudFormation?

A) A fake parameter
B) A parameter predefined by AWS (e.g., AWS::Region, AWS::AccountId)
C) A hidden parameter
D) An optional parameter

See the answer

Answer: B

Pseudo-parameters are automatically provided by AWS: AWS::Region (current region), AWS::AccountId (account ID), AWS::StackName (stack name), AWS::StackId, AWS::NoValue.


Question 14​

What does CloudFormation do if resource creation fails?

A) Continues with others
B) Automatic rollback - deletes created resources and reverts to the initial state
C) Ignores the error
D) Sends an email

See the answer

Answer: B

By default, if a resource fails, CloudFormation performs a rollback: it deletes all resources created during this operation. The stack reverts to its previous state (or is deleted if it was a creation).


Question 15​

How to see why a stack failed?

A) Impossible
B) Check the stack Events in the console or via CLI
C) In S3
D) Via email

See the answer

Answer: B

Stack Events show the status of each resource and error messages. The console displays a timeline. CLI: aws cloudformation describe-stack-events --stack-name StackName.


Question 16​

What is a Change Set?

A) A set of monetary changes
B) A preview of the changes CloudFormation will make to a stack
C) A backup
D) A new template

See the answer

Answer: B

A Change Set shows the changes that will be applied before executing them. It indicates which resources will be added, modified, or deleted. Allows validating changes before applying them.


Question 17​

What is "Drift Detection"?

A) Drift detection
B) Detection of differences between the current configuration and the original template
C) Motion detection
D) Error detection

See the answer

Answer: B

Drift Detection compares the current state of resources with what is defined in the template. It detects manual changes (drift) made outside of CloudFormation. Important for maintaining IaC consistency.


Question 18​

What is a Nested Stack?

A) A hidden stack
B) A stack that includes other stacks as resources
C) A deleted stack
D) A test stack

See the answer

Answer: B

A Nested Stack is a stack created as a resource (AWS::CloudFormation::Stack) in another stack. Allows decomposing complex templates into reusable modules.


Question 19​

What is AWS SAM compared to CloudFormation?

A) A replacement
B) A simplified CloudFormation extension for serverless applications
C) A completely different service
D) An obsolete version

See the answer

Answer: B

AWS SAM (Serverless Application Model) is a CloudFormation extension that simplifies defining Lambda, API Gateway, DynamoDB, etc. SAM templates are transformed into CloudFormation templates during deployment.


Question 20​

How to delete a CloudFormation stack?

A) Delete the template
B) aws cloudformation delete-stack --stack-name StackName or via console
C) Stop the instances
D) It's not possible

See the answer

Answer: B

Delete via console or CLI: aws cloudformation delete-stack --stack-name StackName. CloudFormation deletes all stack resources in the correct order (reverse dependencies). Some resources may have a DeletionPolicy.


Question 21​

What is DeletionPolicy?

A) An employee deletion policy
B) A policy that determines what happens to a resource when the stack is deleted
C) A log retention policy
D) An IAM policy

See the answer

Answer: B

DeletionPolicy defines behavior upon deletion: Delete (removes the resource), Retain (keeps the resource), Snapshot (creates a snapshot before deletion - for RDS, EBS). Protects against accidental deletions.


Question 22​

What is UpdateReplacePolicy?

A) An update policy
B) A policy that determines what happens to a resource when it is replaced during an update
C) A personnel replacement policy
D) A rollback policy

See the answer

Answer: B

UpdateReplacePolicy defines behavior when an update requires resource replacement (Recreation). Similar to DeletionPolicy but for updates that replace.


Question 23​

What is !Condition in CloudFormation?

A) A medical condition
B) Conditional logic to create or not create resources based on parameters
C) An error
D) A loop

See the answer

Answer: B

Conditions allow creating resources conditionally. Example: create a database instance only if the Environment parameter is "Production". Used with !If, !Equals, !And, !Or, !Not.


Question 24​

How to test a CloudFormation template before deployment?

A) Deploy in production
B) aws cloudformation validate-template, Change Sets, or cfn-lint
C) Impossible
D) Via email

See the answer

Answer: B

Methods: aws cloudformation validate-template (syntax), cfn-lint (linter with best practices), Change Sets (change preview), TaskCat (multi-region tests), deployment in a test account.


Question 25​

What is StackSets?

A) Sets of templates
B) Deploy a stack in multiple accounts and regions simultaneously
C) Grouped stacks
D) Stack backups

See the answer

Answer: B

StackSets allows deploying a CloudFormation stack in multiple AWS accounts and/or regions with a single operation. Ideal for organizational configurations (guardrails, compliance).


Question 26​

How to prevent manual modifications on CloudFormation resources?

A) Impossible
B) Stack Policy, restrictive IAM policies, SCPs, and CloudTrail alerts
C) Delete users
D) Encrypt resources

See the answer

Answer: B

Strategies: Stack Policy (protects certain resources from updates), IAM policies (restrict direct modifications), SCPs (at Organization level), CloudTrail alerts for non-CF modifications, regular Drift Detection.


Question 27​

What is cfn-init?

A) CloudFormation initialization
B) A helper script to configure EC2 instances at startup via Metadata
C) A network service
D) A type of template

See the answer

Answer: B

cfn-init is a utility that reads AWS::CloudFormation::Init metadata and configures the instance: install packages, create files, start services. Used with UserData and cfn-signal to signal success.


Question 28​

What is cfn-signal?

A) A radio signal
B) A helper to signal CloudFormation that instance configuration is complete
C) A log
D) A trigger

See the answer

Answer: B

cfn-signal sends a success or failure signal to CloudFormation. Used with CreationPolicy or WaitCondition for CloudFormation to wait until the instance is fully configured before proceeding.


Question 29​

What does LocalStack allow you to do with CloudFormation?

A) Nothing
B) Test CloudFormation templates locally without an AWS account
C) Deploy in production
D) Save templates

See the answer

Answer: B

LocalStack emulates CloudFormation locally. You can test your templates without an AWS account or costs. Use: awslocal cloudformation create-stack --stack-name test --template-body file://template.yaml


Question 30​

What is the best practice for organizing CloudFormation templates?

A) One huge file
B) Break down into modules (nested stacks), use parameters, version with Git
C) No structure
D) One template per resource

See the answer

Answer: B

Best practices: break down into logical modules (network, compute, DB), use nested stacks or cross-stack references, parameterize for reuse, version in Git, name clearly, document with Description and Metadata.


Result​

Count your correct answers:

  • 27-30: Excellent - You master CloudFormation
  • 22-26: Good - Some points to review
  • 17-21: Average - Review the course before the lab
  • Less than 17: Insufficient - Retake the course from the beginning

Proceed to the CloudFormation Lab once you have reached at least 22 correct answers.