CloudFormation Flashcards

This deck aims to help retain concepts related to the AWS CloudFormation service.

1
Q

Which AWS service enables you to model and provision AWS resources using templates written in YAML or JSON?

A

AWS CloudFormation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an AWS CloudFormation Logical Resource?

A

A resource defined in a CloudFormation Template

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an AWS CloudFormation Physical Resource?

A

The actual resource created in an AWS account by a CloudFormation stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which AWS CloudFormation component specifies the resources to be created and their configurations?

A

CloudFormation Template

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can an AWS CloudFormation Template be reused?

A

Yes, it can be reused across multiple accounts and regions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What AWS CloudFormation component creates and manages physical resources based on logical resources defined in a template, ensuring synchronization between them?

A

CloudFormation Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What happens when logical resources in an AWS CloudFormation Template are updated?

A

The stack will be updated, and the corresponding physical resources will be modified to reflect the changes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens if an AWS CloudFormation Stack is deleted?

A

All associated physical resources will also be deleted, unless they are protected or retained

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What AWS CloudFormation Template section is used to explicitly provide input data when a stack is created or updated to customize the resources being created?
Hint: Input data can be provided using console UI, CLI, or API

A

Parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What AWS CloudFormation Template component represents predefined variables that are automatically populated by AWS?

A

Pseudo Parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What properties can an AWS CloudFormation Template Parameter be configured with?

A
  • Description: Provides details about the parameter
  • Default: Specifies a value to use if no input is given
  • AllowedValues: Defines a list of valid options for the parameter
  • AllowedPattern: Specifies a regular expression pattern to validate the input
  • MinValue/MinLength: Sets the smallest acceptable numeric value or string length
  • MaxValue/MaxLength: Sets the largest acceptable numeric value or string length
  • NoEcho: Hides the parameter value, useful for sensitive data
  • Type: Specifies the parameter’s data type (e.g., String, Number, List, CommaDelimitedList)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the most common AWS CloudFormation Pseudo Parameters?

A
  • AWS::Region: Represents the region where the stack is created
  • AWS::AccountId: Represents the account ID where the stack is created
  • AWS::StackName: Represents the name of the stack
  • AWS::StackId: Represents the unique identifier of the stack
  • AWS::NoValue: Removes a resource property
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the main differences between AWS CloudFormation Template Parameters and Pseudo Parameters?

A

Template Parameters:
- Defined by humans when creating a template
- Require explicit input during stack creation or update

Pseudo Parameters:
- Predefined by AWS
- Automatically injected and do not require user input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which AWS CloudFormation Template components provide functionality to dynamically produce values, apply conditionals, and control resource characteristics?

A

Intrinsic Functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What AWS CloudFormation intrinsic function returns the Base64 representation of the input string?

A

Fn::Base64: valueToEncode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What AWS CloudFormation intrinsic function returns an array of CIDR address blocks?

A

Fn::Cidr: - ipBlock - count - cidrBits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What AWS CloudFormation intrinsic functions are used to conditionally create stack resources?

A
  • Fn::Not
  • Fn::And
  • Fn::Or
  • Fn::If
  • Fn::Equals
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What AWS CloudFormation intrinsic function returns the value corresponding to keys in a two-level map?

A

Fn::FindInMap: [ MapName, TopLevelKey, SecondLevelKey ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What AWS CloudFormation intrinsic function takes a collection and a fragment, and applies the items in the collection to the identifier in the provided fragment?

A

'Fn::ForEach::UniqueLoopName': - Identifier - - Value1 # collection - Value2 - 'OutputKey': OutputValue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What AWS CloudFormation intrinsic function returns the value of an attribute from a resource in the template?

A

Fn::GetAtt: [ logicalNameOfResource, attributeName ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What AWS CloudFormation intrinsic function returns an array that lists Availability Zones for a specified Region?

A

Fn::GetAZs: region

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What AWS CloudFormation intrinsic function returns the value of an output exported by another stack?

A

Fn::ImportValue: sharedValueToImport

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What AWS CloudFormation intrinsic function appends a set of values into a single value?

A

Fn::Join: [ delimiter, [ comma-delimited list of values ] ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What AWS CloudFormation intrinsic function returns the number of elements within an array or an intrinsic function that returns an array?

A

Fn::Length : IntrinsicFunction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What AWS CloudFormation intrinsic function returns a single object from a list of objects by index?

A

Fn::Select: [ index, listOfObjects ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What AWS CloudFormation intrinsic function splits a string into a list of string values?

A

Fn::Split: [ delimiter, source string ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What AWS CloudFormation intrinsic function substitutes variables in an input string with values that you specify?

A

Fn::Sub: - String - Var1Name: Var1Value Var2Name: Var2Value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What AWS CloudFormation intrinsic function converts an object or array to its corresponding JSON string?

A

Fn::ToJsonString: Object/Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What AWS CloudFormation intrinsic function specifies a macro to perform custom processing on part of a stack template?

A

Fn::Transform: Name : macro name Parameters : Key : value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What AWS CloudFormation intrinsic function returns the value of the specified parameter or resource?

A

Ref: logicalName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What AWS CloudFormation Template optional section allows to provide keys and values for conditional parameters to improve template portability, supporting one or two-level lookups?

A

Mappings: RegionMap: us-east-1: HVM64: "ami-Off8a91507f77f867" HVMG2: "ami-0a584ac55a7631c0c" us-west-1: HVM64: "ami-0bdb828fd58c52235" HVMG2: "ami-066ee5fd4a9ef77f1"

  • !FindInMap [ “RegionMap”, !Ref ‘AWS::Region’, “HVM64” ]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What AWS CloudFormation Template optional section allows to declare output values for the stack, visible in the CLI, Console UI, and accessible from parent stacks in nested scenarios?

A

Outputs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Can AWS CloudFormation Template Outputs be exported?

A

Yes, Outputs can be exported to allow cross-stack references

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What AWS CloudFormation Template optional section allows to define properties that are processed before resources are created and evaluate to TRUE or FALSE?

A

Conditions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What AWS CloudFormation intrinsic functions are used in the Conditions section?

A
  • Fn::Not
  • Fn::And
  • Fn::Or
  • Fn::If
  • Fn::Equals
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

What AWS CloudFormation Template attribute determines whether a logical resource is created based on a condition?
Hint: TRUE - resource is created, FALSE - resource is not created

A

Condition

Resources: EC2: Type: 'AWS::EC2::Instance' Condition: IsCreated Properties: ...

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

How are implicit dependencies created in an AWS CloudFormation Template?

A

Using intrinsic functions such as !Ref and !GetAtt

Example: IGW attachment that references both a VPC and an IGW

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

How are explicit dependencies created in an AWS CloudFormation Template?

A

Using the DependsOn attribute

Example: EIP explicitly requiring IGW to be attached to a VPC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

How does AWS CloudFormation efficiently determine dependency trees when managing resources?

A
  • Intrinsic functions (!Ref and !GetAtt) for implicit dependencies
  • The DependsOn attribute for explicit dependencies
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What AWS CloudFormation feature is used to signal whether resources like EC2 instances or Auto Scaling Groups (ASGs) have been successfully created or updated?

A

cfn-signal

41
Q

What AWS CloudFormation attribute associated with a resource prevents its status from reaching CREATE_COMPLETE until a specified number of success signals are received or the timeout is exceeded?

A

CreationPolicy

42
Q

Which AWS CloudFormation features can be used to send signals to resources with an associated CreationPolicy?

A
  • cfn-signal
  • SignalResource API call
43
Q

What AWS CloudFormation logical resource is used to pause resource creation until a specific condition is met?

A

AWS::CloudFormation::WaitCondition

44
Q

Can other resources within an AWS CloudFormation template depend on a WaitCondition resource?

A

Yes, resources can depend on the WaitCondition, and the WaitCondition can depend on resources

45
Q

What AWS CloudFormation resource is used to generate a PreSigned URL for other resources to send a signal received by the WaitCondition?

A

AWS::CloudFormation::WaitConditionHandle

46
Q

How can data attached to a signal sent by an EC2 instance to WaitConditionHandle be accessed within an AWS CloudFormation template?

A

By using !GetAtt WaitCondition.Data

47
Q

What is the maximum number of resources that a single AWS CloudFormation stack can support?

A

500 resources

48
Q

What are the two primary approaches for designing multi-stack architectures in AWS CloudFormation?

A
  • Nested Stacks: Enables reusability and modularization of code by embedding templates within parent stacks
  • Cross-Stack References: Facilitates resource sharing across stacks using exported outputs and imports
49
Q

What AWS CloudFormation feature enables the creation of stacks within other stacks, promoting code reuse and modular architecture?

A

Nested Stacks
VPCStack: Type: AWS::CloudFormation::Stack Properties: TemplateURL: https://example.com/template.yaml Parameters: Param1: !Ref SomeParam1 ...

50
Q

What term defines AWS CloudFormation stack that serves as the starting point and may contain one or more nested stacks?

A

Root Stack

51
Q

What term defines AWS CloudFormation stack that includes nested stacks?

A

Parent Stack

52
Q

Can a nested stack in an AWS CloudFormation template contain additional nested stacks?

A

Yes, nested stacks can act as parent stacks to other nested stacks, creating a hierarchy originating from the root stack

53
Q

Can a parent stack directly reference logical resources within a nested stack in AWS CloudFormation?

A

No, a parent stack can only reference the outputs explicitly returned by the nested stack

54
Q

How can the outputs of one AWS CloudFormation nested stack be used as parameters for another nested stack within the same parent stack?

A

By utilizing the DependsOn attribute to define dependencies and passing the required outputs as parameters

55
Q

Can existing resources be reused when creating an AWS CloudFormation nested stack?

A

No, Nested Stacks reuse templates, not resources, each stack defined in the template creates new set of resources when instantiated

56
Q

What are the common use cases for implementing AWS CloudFormation nested stacks architecture?

A
  • When stacks share the same lifecycle
  • To overcome the limit of 500 resources per stack
  • For reusing templates across multiple stacks
57
Q

What AWS CloudFormation feature allows sharing resources between stacks by referencing outputs of one stack in another?

A

Cross-stack References

58
Q

What AWS CloudFormation intrinsic function is used to reference exported outputs in a stack?

A

Fn::ImportValue: sharedValueToImport

59
Q

What naming restrictions apply to exported values when using AWS CloudFormation Cross-stack References?

A

Exported values must have a unique name within the same AWS region and account

60
Q

Where in an AWS CloudFormation template are values defined for export when using Cross-stack references?

A

In the Outputs section, under the Export key

61
Q

What are the common scenarios for using AWS CloudFormation Cross-stack References?

A
  • When stacks have independent lifecycles
  • When resources from one stack need to be utilized by another stack
62
Q

What AWS CloudFormation feature allows centralized management of stacks across multiple accounts and regions, enabling creation, updates, and deletions in a single operation using an administrator account and a shared template?

A

Stack Sets

63
Q

In AWS CloudFormation, what acts as a container for managing stack instances within the administrator account?

64
Q

When using AWS CloudFormation Stack Sets, what represents a reference to a stack created in a target account?

A

Stack Instance

65
Q

How can permissions be granted to AWS CloudFormation Stack Sets?

A
  • self-managed IAM Roles: created and managed by the customer
  • service-managed IAM Roles: created and managed by AWS CloudFormation
66
Q

What option in AWS CloudFormation Stack Sets defines the maximum number or percentage of target accounts where an operation runs simultaneously?

A

Concurrent Accounts

67
Q

What option in AWS CloudFormation Stack Sets defines the maximum number or percentage of stack operation failures allowed per region, beyond which CloudFormation halts the operation automatically?

A

Fault Tolerance

68
Q

What AWS CloudFormation Stack Sets option allows stacks and their resources to remain running even after stack instances are removed from a stack set?

A

Retain Stacks

69
Q

What are the common use cases for implementing AWS CloudFormation Stack Sets?

A
  • Enable AWS Config across multiple accounts
  • Create AWS Config rules, such as MFA, Elastic IPs, and EBS Encryption
  • Deploy IAM roles for cross-account access at scale
70
Q

Which AWS CloudFormation attribute helps retain or backup a resource when its stack is deleted?

A

DeletionPolicy

Resources: MyBucket: Type: AWS::S3::Bucket DeletionPolicy: Retain

71
Q

What are the types of deletion policies available in AWS CloudFormation?

A
  • Delete - removes the resource and its contents (default)
  • Retain - keeps the resource and its contents after stack deletion
  • RetainExceptOnCreate - retains the resource except in cases of a creation rollback
  • Snapshot - creates a snapshot of the resource before deletion (for resources that support snapshots)
72
Q

Which AWS CloudFormation deletion policy retains a resource and its contents when the stack is deleted?

A

Retain - ensures that the resource and its contents are preserved during stack deletion

73
Q

Which AWS CloudFormation deletion policy is applied by default when the DeletionPolicy attribute is not specified?

A

Delete - removing the resource and its contents during stack deletion

74
Q

Which AWS CloudFormation deletion policy retains resources and their content during stack deletion, except in the case of a rollback for the initial stack creation?

A

RetainExceptOnCreate - retains resources and their content unless the operation is a creation rollback

75
Q

Is the AWS CloudFormation deletion policy applied during both resource deletion and replacement operations?

A

No, the deletion policy is applied only during DELETE operations

76
Q

Which AWS CloudFormation deletion policy creates a backup snapshot of a resource when its stack is deleted?

A

Snapshot - ensures that a snapshot of the resource is created, persisting beyond the stack’s lifetime, snapshots may incur additional charges

77
Q

What credentials are used by default during AWS CloudFormation stack creation?

A
  • The credentials of the IAM principal performing the stack operation
  • The principal must have the necessary permissions to create, update, or delete the stack and its associated resources
78
Q

What feature allows AWS CloudFormation to create, update, or delete resources on behalf of users, enabling role separation?

A

Service role (Stack Role)

79
Q

How is a service role implemented in AWS CloudFormation?

A
  1. Admin creates an IAM role with permissions to create, update, and delete AWS resources
  2. Users are granted permissions to create, update, and delete stacks and to pass the service role
  3. The service role is attached to the stack during creation, enabling it to manage AWS resources
80
Q

What is the use case for AWS CloudFormation Stack Roles?

A

When identities need to interact with CloudFormation stacks but should not have direct permissions to create, update, or delete AWS resources

81
Q

What AWS CloudFormation feature facilitates configuration management on EC2 instances through helper scripts executed via user data?

82
Q

Where are configuration directives for the AWS CloudFormation cfn-init feature defined?

A

In the Metadata attribute of an EC2 instance’s logical resource, using the AWS::CloudFormation::Init type

83
Q

What will happen if AWS CloudFormation cfn-init feature is used to start a service that is already started?

A

Nothing, cfn-init is idempotent

84
Q

What AWS CloudFormation feature provides a helper daemon that can be installed on an EC2 instance to detect changes in resource metadata and trigger user-defined actions in response?

85
Q

What action is commonly triggered when AWS CloudFormation’s cfn-hup daemon detects changes in logical resource metadata?

A

Typically, cfn-hup triggers a rerun of the cfn-init configuration script to reapply the desired state of the instance

86
Q

Which AWS CloudFormation feature previews the impact of proposed changes to stack resources, properties, or attributes before execution?

A

Change Sets

87
Q

How can critical resource deletions or replacements in an AWS CloudFormation Change Set be avoided?

A

Changes to the stack occur only after the Change Set is executed

To avoid undesired changes, review the Change Set and create a new one with adjusted modifications if necessary

88
Q

Which AWS CloudFormation API methods are used to manage Change Sets?

A
  • aws cloudformation create-change-set
  • aws cloudformation list-change-sets
  • aws cloudformation describe-change-set
  • aws cloudformation execute-change-set
  • aws cloudformation delete-change-set
89
Q

What AWS CloudFormation feature enables custom provisioning logic for resources not covered by built-in resource types, executed during resource creation, update, or deletion?

A

Custom Resources

90
Q

What AWS CloudFormation resource type is used to define a Custom Resource?

A

Custom::CustomResourceTypeName

CustomS3Objects:
  Type: "Custom::S3Objects"
  Properties:
    ServiceToken: !GetAtt LambdaFunction.Arn
    Key1: "val-1"
    Key2: "val-2"
91
Q

What required AWS CloudFormation Custom Resources property defines the endpoint to send an event (e.g., AWS Lambda or SNS Topic) when a custom resource is created, updated, or deleted?

A

ServiceToken

92
Q

In which order are AWS CloudFormation Custom Resources created by default?

A

Custom Resources are created in dependency order

If a custom resource is defined last in the template, it will be created last and deleted first

93
Q

Provide an example use case for AWS CloudFormation Custom Resource.

A

A Lambda function that populates an S3 bucket with objects upon creation and removes objects from the bucket before deletion

94
Q

How does AWS CloudFormation know that a custom resource was successfully created by AWS Lambda?

A

Event object provided to Lambda contains a ResponseURL, which Lambda uses to notify the stack of the resource’s successful creation or deletion

95
Q

Which section of an AWS CloudFormation template cannot be associated with a Condition?

A

Parameters section

96
Q

Do exported values in AWS CloudFormation need to have unique names across all AWS Regions?

A

No, they only need to be unique within a single AWS Region

97
Q

What type of Parameter in AWS CloudFormation helps catch invalid values for AWS resource attributes during stack creation or updates?

A

AWS-specific parameter types, such as:
- AWS::EC2::VPC::Id - AWS::EC2::Subnet::Id`

98
Q

What CLI command packages local artifacts referenced in a CloudFormation template and uploads them, such as source code for AWS Lambda functions?

A

cloudformation package

99
Q

What CLI command deploys an AWS CloudFormation template by creating and executing a changeset?

A

cloudformation deploy