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

References to created resources; can be exported for cross-stack use.

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 to allow CFN to manage resources on your behalf.

23
Q

What are CAPABILITY_NAMED_IAM and CAPABILITY_IAM?

A

Capabilities to allow creation of IAM resources via CloudFormation.

24
Q

What is CAPABILITY_AUTO_EXPAND?

A

Used when templates use Macros or Nested Stacks.

25
Q

What is DeletionPolicy in CloudFormation?

A

Controls what happens when a resource is deleted.

26
Q

What does DeletionPolicy Retain do?

A

Keeps the resource after stack deletion.

27
Q

What does DeletionPolicy Snapshot do?

A

Creates a snapshot before deleting a resource.

28
Q

What is a Stack Policy?

A

Defines what resources can be updated during a stack update.

29
Q

How to prevent accidental stack deletion?

A

Enable TerminationProtection.

30
Q

What are Custom Resources in CloudFormation?

A

Define custom provisioning logic using Lambda or SNS.

31
Q

What is a use case for Custom Resources?

A

Empty an S3 bucket before deletion.

32
Q

What are CloudFormation StackSets?

A

Manage stacks across multiple accounts and regions from one template.

33
Q

What is AWS CDK?

A

A framework to define cloud infrastructure using programming languages like JavaScript, TypeScript, Python, Java, and .NET.

34
Q

What are CDK constructs?

A

Components that encapsulate everything CDK needs to create the final CloudFormation stack.

35
Q

What is the purpose of CDK synth?

A

It synthesizes and prints the CloudFormation template from your CDK code.

36
Q

What is CDK bootstrap?

A

It deploys the CDK Toolkit stack that includes necessary resources like an S3 bucket and IAM roles.

37
Q

What are CDK L1 constructs?

A

Low-level constructs mapped directly to CloudFormation resources, names start with ‘Cfn’.

38
Q

What are CDK L2 constructs?

A

Higher-level constructs with convenient defaults and intent-based APIs.

39
Q

What are CDK L3 constructs?

A

High-level patterns that include multiple related AWS resources for common architectures.

40
Q

What does ‘cdk deploy’ do?

A

Deploys the stack(s) to AWS.

41
Q

What does ‘cdk diff’ do?

A

Compares local CDK stack with the deployed stack and shows the differences.

42
Q

What is the use of ‘cdk destroy’?

A

Destroys the deployed stack(s) in AWS.

43
Q

What is CDK Toolkit?

A

A CloudFormation stack created by CDK bootstrap containing an S3 bucket and IAM roles.

44
Q

What happens if CDK is not bootstrapped?

A

You get an error about invalid principal in the policy.

45
Q

How can CDK be tested?

A

Using CDK Assertions with test frameworks like Jest or Pytest.

46
Q

What are fine-grained assertions in CDK testing?

A

Tests that check specific aspects of a resource in the CloudFormation template.

47
Q

What are snapshot tests in CDK?

A

Tests that compare the synthesized template to a stored baseline template.

48
Q

How to initialize a CDK app?

A

Use the command ‘cdk init app’.

49
Q

What command installs the CDK CLI?

A

npm install -g aws-cdk-lib

50
Q

What command deploys resources using CDK?

A

cdk deploy

51
Q

What command destroys a CDK stack?

A

cdk destroy

52
Q

What is the Construct Hub in CDK?

A

A collection of additional constructs provided by AWS, 3rd parties, and the open-source community.