CloudFormation and CDK Flashcards

1
Q

What is AWS CloudFormation?

A

A declarative service to outline and manage AWS infrastructure as code.

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

What are the benefits of CloudFormation?

A

Infrastructure as code, version control, cost estimation, productivity, reusable templates.

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

How does CloudFormation work?

A

Templates define resources, uploaded to S3, and referenced by CloudFormation to create/update stacks.

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

What happens when a stack is deleted?

A

All resources created by the stack are deleted.

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

What are CloudFormation building blocks?

A

Resources (mandatory), Parameters, Mappings, Outputs, Conditionals, References, Functions.

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

Which languages are used for CloudFormation templates?

A

YAML and JSON; YAML is preferred.

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

What are CloudFormation resources?

A

Core components of a template that define AWS infrastructure.

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

Can CloudFormation create dynamic number of resources?

A

Yes, using Macros and Transforms.

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

What are CloudFormation Parameters?

A

Inputs to templates for reuse and dynamic configuration.

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

When should you use Parameters?

A

When values are user-specific or likely to change.

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

What are CloudFormation Mappings?

A

Fixed variables to differentiate values like region or environment.

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

How to access Mapping values?

A

Use Fn::FindInMap.

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

When to use Mappings vs Parameters?

A

Mappings for predictable values, Parameters for dynamic inputs.

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

What are CloudFormation Outputs?

A

Named values you can declare in your template to return information about the resources that were created. Share values with other stacks (cross-stack references).

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

How to use cross-stack references?

A

Use Fn::ImportValue in the referencing stack.

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

What are CloudFormation Conditions?

A

Logic to create resources based on parameter values or environment.

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

How to use a Condition in a resource?

A

Attach a Condition with logical functions like Fn::If.

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

What is Fn::Ref used for?

A

Reference parameters and resources.

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

What does Fn::GetAtt do?

A

Get attributes from a resource (e.g., AZ from an EC2 instance).

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

What does Fn::Base64 do?

A

Encodes a string to Base64, e.g., for EC2 UserData.

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

What happens when stack creation fails?

A

Rolls back all created resources unless rollback is disabled.

22
Q

What is a CloudFormation Service Role?

A

IAM role that AWS CloudFormation assumes on your behalf to create, update, or delete stack resources.

23
Q

What are CAPABILITY_NAMED_IAM and CAPABILITY_IAM?

A

Explicit acknowledgments you must provide when your CloudFormation template creates or modifies IAM resources

24
Q

What is CAPABILITY_AUTO_EXPAND?

A

Used when templates use Macros or Nested Stacks.

25
What is DeletionPolicy in CloudFormation?
Controls what happens when a resource is deleted.
26
What does DeletionPolicy Retain do?
Keeps the resource after stack deletion.
27
What does DeletionPolicy Snapshot do?
Creates a snapshot before deleting a resource.
28
What is a Stack Policy?
Defines what resources can be updated during a stack update.
29
How to prevent accidental stack deletion?
Enable TerminationProtection.
30
What are Custom Resources in CloudFormation?
Define custom provisioning logic using Lambda or SNS.
31
What is a use case for Custom Resources?
Empty an S3 bucket before deletion.
32
What are CloudFormation StackSets?
Manage stacks across multiple accounts and regions from one template.
33
What is AWS CDK?
A framework to define cloud infrastructure using programming languages like JavaScript, TypeScript, Python, Java, and .NET.
34
What are CDK constructs?
Components that encapsulate everything CDK needs to create the final CloudFormation stack.
35
What is the purpose of CDK synth?
It synthesizes and prints the CloudFormation template from your CDK code.
36
What is CDK bootstrap?
It deploys the CDK Toolkit stack that includes necessary resources like an S3 bucket and IAM roles.
37
What are CDK L1 constructs?
Low-level constructs mapped directly to CloudFormation resources, names start with 'Cfn'.
38
What are CDK L2 constructs?
Higher-level constructs with convenient defaults and intent-based APIs.
39
What are CDK L3 constructs?
High-level patterns that include multiple related AWS resources for common architectures.
40
What does 'cdk deploy' do?
Deploys the stack(s) to AWS.
41
What does 'cdk diff' do?
Compares local CDK stack with the deployed stack and shows the differences.
42
What is the use of 'cdk destroy'?
Destroys the deployed stack(s) in AWS.
43
What is CDK Toolkit?
A CloudFormation stack created by CDK bootstrap containing an S3 bucket and IAM roles.
44
What happens if CDK is not bootstrapped?
You get an error about invalid principal in the policy.
45
How can CDK be tested?
Using CDK Assertions with test frameworks like Jest or Pytest.
46
What are fine-grained assertions in CDK testing?
Tests that check specific aspects of a resource in the CloudFormation template.
47
What are snapshot tests in CDK?
Tests that compare the synthesized template to a stored baseline template.
48
How to initialize a CDK app?
Use the command 'cdk init app'.
49
What command installs the CDK CLI?
npm install -g aws-cdk-lib
50
What command deploys resources using CDK?
cdk deploy
51
What command destroys a CDK stack?
cdk destroy
52
What is the Construct Hub in CDK?
A collection of additional constructs provided by AWS, 3rd parties, and the open-source community.