IuriiO Notebook
  • Broken Code Notebook
  • Architecture and Design
    • Architectural Decision Records
    • Trade-off Analysis
    • Data Decomposition Drivers
    • Selecting a Database Type
    • Service Granularity
    • Consumer-driven Contracts
  • Cloud
    • AWS
      • Resources
      • Compute
        • EC2
        • Batch
        • ECS & ECR
        • Elastic Beanstalk
      • Storage & Data Management
        • S3
        • Storage Gateway
        • RDS
        • DynamoDB
        • ElastiCache
        • Redshift
        • EBS
        • EFS
        • FSx
        • Snowball
        • Athena
        • Encryption and Downtime
        • Untitled
      • Security & Compliance
        • IAM
        • Web Identity Federation
        • Organizations
        • Service Catalog
        • Tags and Resource Groups
        • STS
        • KMS
        • GuardDuty
        • Compliance
        • Marketplace Security Products
        • DDOS
        • Compliance Frameworks
      • High Availability
        • Global Infrastructure
        • Disaster recovery
        • Elastic Load Balancers
        • Untitled
      • Monitoring & Reporting
        • Cost Explorer
        • CloudWatch
        • Systems Manager
        • Config
        • CloudTrail
        • Cost control
        • Untitled
      • Networking
        • Networking 101
        • Route53
        • CloudFront
        • VPC
        • DirectConnect
        • WAF
        • Shield
        • Global Accelerator
      • Deployment & Provisioning
        • Untitled
        • Untitled
      • Automation & Optimization
        • CloudFormation
          • Links
          • Github resources
          • YAML 101
          • Videos
        • OpsWorks
        • Untitled
      • Application Services
        • SQS
        • SWF
        • SNS
        • Untitled
      • Serverless
        • Lambda
        • API Gateway
        • DynamoDB
        • SAM
        • Untitled
      • Well-Architected Framework
    • Azure
      • Tools
      • Organization & Management
      • Authentication & Authorization
      • Compute
      • Networking
      • Storage
      • Databases
      • Security
      • Privacy, Compliance & Trust
      • Cost Management
  • Containers & Services
    • Docker
      • Useful Links
      • Containers
      • Images
      • Dockerfile
      • System
      • Compose
      • Swarm
      • Docker & NodeJS
    • Kubernetes
      • Useful Links
      • Introduction
      • Getting started
      • Exposing containers
      • Kubernetes Management Techniques
        • Declarative YAML
      • Labels and Annotations
      • Storage in Kubernetes
      • Ingress Controller
      • CRD's and The Operator Pattern
      • Kubernetes Dashboard
      • Kubectl Namespaces and Context
  • Frontend
    • Resources
    • Design
      • Search experience
Powered by GitBook
On this page
  • Key/value pairs
  • Lists
  • Dictionaries
  • Lists with Dictionaries
  • Lists with Dictionaries containing Lists
  • Pipes
  • Greater than
  • Comments
  • Anchor / merge

Was this helpful?

  1. Cloud
  2. AWS
  3. Automation & Optimization
  4. CloudFormation

YAML 101

Key/value pairs

  • YAML document consists of key/value pairs

  • Key/value pairs are separated by colon followed by space

  • Supports different data types

    • Integers

    • Floating-point numbers

    • Strings, enclosed with quotes if they have special symbols

    • Boolean

    • Binary

    • Dates, in ISO:8601 format

    • Null value

Name: Dave
Age: 25
GPA: 4.2
Occupation: Engineer
State: 'New Jersey'
About: "I'm a software engineer"
Score: null
Male: true
DateOfBirth: 1990-09-15T19:07:00

Lists

  • YAML lists are indented with a dash

  • All items are on the same level

  • There are 2 types of writing arrays:

    • Block sequence - each entry indicated with a dash followed by a space

    • Flow sequence - all elements are on the same line, separated with commas and enclosed by [].

PeopleBlock:
  - John
  - Mike
  - Tom
  - Jake

PeopleFlow: [John, Mike, Tom, Jake]

Dictionaries

  • A set of properties grouped under an item

  • Dictionaries contain key/value pairs

Dave:
  Age: 25
  GPA: 4.2
  Occupation: Engineer
  State: 'New Jersey'
  About: "I'm a software engineer"
  Score: null
  Male: true
  DateOfBirth: 1990-09-15T19:07:00

Lists with Dictionaries

Personnel:
  - Dave:
      Age: 24
      Occupation: Engineer
      State: CA
  - Mike:
      Age: 30
      Occupation: Manager
      State: TX
  - John:
      Age: 40
      Occupation: Designer
      State: WA

Lists with Dictionaries containing Lists

Personnel:
  - Dave:
      Age: 24
      Occupation: Engineer
      State: CA
      Degrees:
      	- Bachelor
      	- Masters
      	- PHD
  - Mike:
      Age: 30
      Occupation: Manager
      State: TX
      Degrees: [Bachelor, Masters]
  - John:
      Age: 40
      Occupation: Designer
      State: WA
      Degrees:
      	- Masters

Pipes

  • Pipe notation is also referred as literal block

  • All new lines, indentation, extra spaces are preserved

Resource:
  Name: My resource
  Description: |
    This is a description,
    with new lines and | special symbols
  Prop: value

Greater than

  • Also referred as folded block

  • Renders the text as a single line

  • All new lines will be replaced with a single space

  • Blank lines are converted to a new line character

Resource:
  Name: My resource
  Description: >
    This is a description,
    with new lines and | special symbols

    Will render everything as a single line
  Prop: value

Comments

  • Comments are defined with '#' symbol

# resource definition
Resource:
  Name: My resource

Anchor / merge

  • Allows to define and reference blocks

  • CloudFormation has very limited support for anchors

MyAnchor: &a
  Prop1: value1
  Prop2: value2

AnotherPlace:
  <<: *a
  Prop3: value3

PreviousGithub resourcesNextVideos

Last updated 4 years ago

Was this helpful?