Cloud Formation — Basics

June Chung
2 min readNov 4, 2020
  1. Parameters — defines the variables that will be used in the template (definition & scope)
  2. Mapping — fixed variables within template
  3. Resources — actual allocation/definition happens

Mapping
fixed set of variables — used depending on situation

<< This means… if you’re us-east-1 and using 32 bit, you will use this ami

If want to use + don’t want to search for your self
: !FindInMap [RegionMap, !Ref “AWS::Region”, 32]

  • The “depends on” attribute (in resources) — is to tell CF that you want to create something before creating a resource

YAML BASICS

  • Normally all the commands & yaml file would be single quote ‘ ’
  • If special occasion, can use double quote “ ”
    In general, you don’t need quotes.

Got data from stack over flow : https://stackoverflow.com/questions/19109912/yaml-do-i-need-quotes-for-strings-in-yaml

  • Use quotes to force a string, e.g. if your key or value is 10 but you want it to return a String and not a Fixnum, write '10' or "10".
  • Use quotes if your value includes special characters, (e.g. :, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, \).
  • Single quotes let you put almost any character in your string, and won’t try to parse escape codes. '\n' would be returned as the string \n.
  • Double quotes parse escape codes. "\n" would be returned as a line feed character.
  • The exclamation mark introduces a method, e.g. !ruby/sym to return a Ruby symbol.

Seems to me that the best approach would be to not use quotes unless you have to, and then to use single quotes unless you specifically want to process escape codes.

--

--