Flashcards in Section 10: AWS CloudFormation Deck (73)
Loading flashcards...
1
Q

Why is manual work (clicking in the consoleโ€ฆ) not very good?

A

Hard to reproduce

2
Q

What is CloudFormation?

A

A declarative way of outlining your AWS

Infrastructure, for any resources

3
Q

Which resources are supported by AWS CloudFormation?

A

Most of them

4
Q

Do you have to specify a creation order for the resources in a CloudFormation template?

A

No, you write your templates in a declarative way and CloudFormation will take care of creating the resources in the right order

5
Q

In what file type can you write CloudFormation templates?

A

JSON or YAML

6
Q

What does IaC stand for?

A

Infrastructure as Code

7
Q

What are the benefits of IaC

A

No manual work
You get version control just like regular code
You can review your infrastructure easily through code
You get easy deployments

8
Q

What are the cost of CloudFormation?

A

No additional cost

You only pay for the underlying resources

9
Q

How can you estimate the cost of a CloudFormation stack?

A

By using the provided tool for that purpose in CloudFormation

10
Q

What is a good savings strategy for development environments when using CloudFormation?

A

You can automate the deletion of templates at 5PM and creation of templates at 8AM (So that you donโ€™t pay for dev environment when you are not using it at night)

11
Q

What are the productivity benefits of CloudFormation?

A

Ability to create and destroy stacks on the fly
You get automated generation of diagrams
No need to figure out ordering and orchestration of your infrastructure

12
Q

How to do seperation of concerns with CloudFormation?

A

Create many stacks for many apps and many layers

13
Q

Where must CloudFormation templates be uploaded to in order to be able to use them?

A

In S3

14
Q

How can you update a CloudFormation stack?

A

By reuploading a new version to AWS

15
Q

How are stacks identified in CloudFormation?

A

By name

16
Q

What happens to the underlying resources when you delete a stack?

A

They get deleted

17
Q

What is the manual way of deploying a CloudFormation stack?

A

By editing templates in the CloudFormation Designer

Using the console to input parameters

18
Q

What is the automated way of deploying a CloudFormation stack?

A

Editing templates in a YAML file

Using the CLI to deploy the templates

19
Q

What is the recommended way to deploy CloudFormation templates?

A

The automated way

20
Q

What are the building blocks of CloudFormation templates?

A

Templates components

Templates helpers

21
Q

What are the CloudFormation templates helpers?

A

References

Functions

22
Q

What are the CloudFormation templates components?

A
Resources
Parameters
Mappings
Outputs
Conditionals
Metadata
23
Q

Which CloudFormation templates component is mandatory?

A

Resources

24
Q

What does YAML stand for?

A

YAML Ainโ€™t Markup Language (A recursive acronym)

25
Q

What can be in a YAML file?

A
Key value pairs
Nested objects
Arrays
Multi line string
Comments
26
Q

What do key value pairs look like in YAML?

A

key: value

27
Q

What do nested objects look like in YAML?

A

key:
param1: value1
param2: value2
otherKey: otherValue

28
Q

What do arrays look like in YAML?

A

keys:

  • โ€œoneโ€
  • โ€œtwoโ€
  • โ€œthreeโ€
29
Q

What do multi line string look like in YAML?

A

myString: |
I am a
multiline string

30
Q

What do comments look like in YAML?

A

This is a comment

31
Q

What are resources in a CloudFormation template?

A

AWS Components/Resources that will get created and configured

32
Q

What is the form of resource types identifiers?

A

AWS::aws-product-name::data-type-name

33
Q

Can you create a dynamic amount of resources directly in a CloudFormation template?

A

No, CloudFormation templates are declarative, everything has to be declared

34
Q

What are the two fields that every resource declared in a CloudFormation template must contain?

A

Type: AWS::XXX:XXX
Properties:
Property1: value1
Property2: value2

35
Q

How to know what properties are available on what AWS resources types?

A

By looking at the CloudFormation documentation for the corresponding AWS resource

36
Q

What are CloudFormation parameters?

A

A way to provide inputs to your AWS CloudFormation

template

37
Q

When should you use CloudFormation parameters?

A

When a certain resource configuration is likely to change in the future

38
Q

What are the settings of a CloudFormation parameter?

A
Type
Description
ConstraintDescription
Min/MaxLenght
Min/MaxValue
Default
AllowedValues (array)
AllowedPattern (regexp)
NoEcho (bool)
39
Q

What are the available types of CloudFormation parameters?

A
String
Number
List
CommaDelimitedList
AWS Parameter
40
Q

What is the โ€œAWS parameter typeโ€ used for in CloudFormation parameters?

A

A way to help catch invalid values - match against existing values in the AWS account

41
Q

What can you do to make sure a CloudFormation parameter matches a certain pattern?

A

Define the AllowedPattern parameter setting

42
Q

What can you do to make sure a CloudFormation parameter matche is between a certain range?

A

Define the Min/MaxLenght for String

Define the Min/MaxValue for Number

43
Q

What does the parameter setting NoEcho does?

A

It displays the parameter value as *** in the console in order to mask the value

44
Q

How to reference a parameter in a CloudFormation template?

A

By using the Fn::ref function

45
Q

What is an other/cleaner way of using a Fn::ref function?

A

By using the !ref syntax

46
Q

What are pseudo parameters?

A

Parameters directly provided by AWS

47
Q

How to reference the account id in a CloudFormation template?

A

By using the AWS::AccountId pseudo parameter like so:

!ref โ€œAWS::AccountIdโ€

48
Q

What are the available pseudo parameters in CoudFormation?

A
AWS::AccountId
AWS::NotificationARNs
AWS::NoValue
AWS::Partition
AWS::Region
AWS::StackId
AWS::StackName
AWS::URLSuffix
49
Q

What does the AWS::NoValue pseudo parameters give us

A

They allow us to removes the corresponding resource property when specified as a return value in the Fn::If intrinsic function

DBSnapshotIdentifier:
      Fn::If:
      - UseDBSnapshot
      - Ref: DBSnapshotName
      - Ref: AWS::NoValue
50
Q

What are mappings?

A

Mappings are fixed variables within your CloudFormation Template

51
Q

What are they good for?

A

Handy to differentiate between env, regions, AMI types, etc.

52
Q

Where are mappings value defined?

A

Within the template

53
Q

When should you use mappings instead of parameters?

A

When you know in advance all the values that can be used and the circumstances when each value must be used

54
Q

Which are safer, mappings or parameters?

A

Mappings

55
Q

How to define mappings in your template?

A

In the Mappings section of your template, you must define the mapping, the top level keys and second levels keys
For example:

Mappings:
    MyFirstMapping:
        TopLevelKey1:
            SecondLevelKey1:
            SecondLevelKey2:
        TopLevelKey2:
            SecondLevelKey1:
            SecondLevelKey2:
56
Q

How to access mapping values?

A

With the Fn::FindInMap function

!FindInMap [MapName, TopLevelKey, SecondLevelKey]

57
Q

What are Outputs in CloudFormation?

A

Optional values that can be imported into other stacks

58
Q

Where can you view CloudFormation outputs?

A

In the AWS console or using the AWS CLI

59
Q

How are outputs useful?

A

They are useful when you have something like a network CloudFormation stack and you want to output the variables such as VPC ID and Subnet IDs

60
Q

What happens if you try to delete a stack which outputs are used by another stack

A

It wonโ€™t be able to delete

61
Q

How to import values from the outputs of another CloudFormation stack?

A

By using the Fn::ImportValue function

62
Q

What are conditions used for in CloudFormation?

A

Used to control the creation of resources or outputs based on a condition

63
Q

What are some common conditions which are used in a CloudFormation template based on?

A

Environment

Region

64
Q

Can conditions reference other conditions

A

Absolutely

65
Q

How/Where do you define conditions in a CloudFormation template

A

In the Conditions section of the template, for example:

Conditions:
CreateProdResource: !Equals [!Ref EnvType, prod]

66
Q

How to use a condition when creating a resource?

A

You use the Condition field like so:

Resources:
MyResource:
Type: โ€œAWS::PRODUCT::TYPEโ€
Condition: MyCondition

67
Q

What does the Fn::GetAtt allows you to get?

A

Available attributes that are attached to any resources you create (See the docs to know which attributes are available)

68
Q

What does the Fn::Ref function allow you to get?

A

Parameters (Value of the parameters)

Resources (ID of the underlying resource)

69
Q

What does the Fn::Join function allow you to do?

A

Join values with a delimiter, for example:

!Join [โ€:โ€, [a,b,c]]

This create โ€œa:b:cโ€

70
Q

What does the Fn::Sub function allow you to do?

A

Substitute variables from a text, for example:

Name: !Sub

  • www.${Domain}
  • { Domain: !Ref RootDomainName }
71
Q

What are the available intrinsic condition functions in CloudFormation?

A
Fn::And
Fn::Equals
Fn::If
Fn::Not
Fn::Or
72
Q

What happens by default if a stack creation fails?

A

Everything rolls back (get deleted since itโ€™s a creation)

73
Q

What happens by default if a stack update fails?

A

Everything rolls back to the previous known working version