What is YAML?

πHello, Hashnode community! I'm subbaramireddy, a passionate DevOps Engineer with a relentless commitment to optimizing software development workflows and infrastructure management. π Hands-on experience in the DevOps field, I've honed my skills in AWS cloud services, containerization, and CI/CD pipelines. As an AWS Certified Developer, I'm well-versed in leveraging cloud technologies to drive efficiency and innovation. π‘ I firmly believe in the power of continuous improvement. My journey began with an internship, where I immersed myself in the intricacies of DevOps, from deploying web applications to orchestrating containerized solutions. I've also delved into AWS CDK, enhancing security through RDS instance policies, and creating foundational infrastructure with precision. π My goal is to share insights, best practices, and the latest trends in the DevOps landscape. I'm excited to connect with like-minded professionals, engage in meaningful discussions, and learn from the diverse experiences of the Hashnode community. π Let's explore the ever-evolving world of DevOps together. Feel free to connect with me, ask questions, or share your own insights. Together, we can drive innovation and efficiency in the tech world!
YAML is a data serialization language for storing information in a human-readable form.
YAML stands for "YAML Ain't Markup Language."
YAML is not a Markup Language.
YAML is used to store complex data in a compact and readable format.
YAML was originally designed as a configuration language but is now used in various applications.
We can use YAML to define key and value pairs like variables, lists and objects
YAML is very similar to JSON (Javascript Object Notation) and XML (Extensible Markup Language)
YAML primarily focuses on readability and user-friendliness.
YAML is designed to be clean and easy to read.
We can define YAML files with two different extensions.
.yml.yaml
YAML BASICS
YAML Comments
YAML Key-Value Pairs
YAML Dictionary or Map
YAML Array / Lists
YAML Pipe
YAML Greater than Sign
YAML Document Separator
YAML Comments
- We can have comments in YAML with a
#sign. Below is an example.
#YAML Tutorial
#Written by Ram
YAML β Key-Value Pairs
YAML documents will be full of key-value pairs.
Key and Value are separated by a colon.
We must have a space after the colon differentiating the value.
YAML Supports different data types.
IntegerFloating point NumbersStringsBooleanDates - Format: ISO 8601Null valuesImportant Note for Strings: Quote strings when they have special characters like colons :, braces {}, pipes |, brackets []
#Key Value Pairs
Name: Ram
Age: 22
Gpa: 9.0
Occupation: DevOps Engineer
State: 'Andhra Pradesh [AP]'
AboutMe: "I am a DevOps engineer"
Male: true
DateOfBith: 2001-11-26T15:53:00
PoliceCases: null
Strings are a collection of characters that represent a sentence or phrase. You either use | to print each string as a new line or > to print it as a paragraph.
Strings in YAML do not need to be in double quotes.
#DatatTypes Examples
integer: 25
hex: 0x12d4 #evaluates to 4820
octal: 023332 #evaluates to 9946
float: 25.0
exponent: 12.3015e+05 #evaluates to 1230150.0
boolean: Yes
string: "25"
infinity: .inf # evaluates to infinity
neginf: -.Inf #evaluates to negative infinity
not: .NAN #Not a Number
YAML Array / Lists
YAML List is indented with an opening dash.
Dash indicates that itβs an element of an array.
All members of a list are lines beginning at the same indentation level starting with a β-β (a dash and a space)
Block Sequence indicates each entry with a dash and space
Flow Sequence is written as a comma-separated list within square brackets
#Block Sequence
Persons:
- Ram
- Bhadra
- Sravan
- Ravi
#Flow Sequence
Persons: [Ram, Bhadra, Sravan, Ravi]
YAML Dictionary or Map
Dictionaries are collections of key-value pairs all nested under the same subgroup. They help to divide data into logical categories for later use.
Dictionaries are defined like mappings in that you enter the dictionary name, a colon, and a space followed by one or more indented key-value pairs.
person:
name: Ram
age: 22
city: kadapa
YAML lists containing dictionaries containing lists
Persons:
- Ram:
Age: 22
Occupation: DevOps Engineer
State: London
Degrees:
- Bachelors
- Masters
- Ravi:
Age: 22
Occupation: Developer
State: California
Degrees: [Bachelors, Masters] # List with a differnt notation
- Sravan:
Age: 23
Occupation: Cloud Developer
State: Texas
Degrees:
- Masters
YAML Pipe
The pipe notation is also referred to as a literal block.
All new lines, indentation, extra spaces everything preserved as is.
str: Hello World
data: |
These
Newlines
Are broken up
YAML Greater than Sign
The greater-than-sign notation is also referred to as a folded block.
Renders the text as a single line.
All new lines will be replaced with a single space.
Blank lines are converted to newline characters.
str: Hello World
data: >
This text is
wrapped and is a
single paragraph
YAML Document Separator
You can have multiple YAML documents in a single YAML file to make file organization or data parsing easier.
The separation between each document is marked by three dashes (
---)
---
person: Ram
Hobbies: cooking
---
player: Ravi
action: cycling
---
Thanks for reading! I hope you found this helpful and informative.
I'm always happy to connect with fellow tech enthusiasts and answer any questions you may have. Don't forget to follow me for more updates on tech, programming, and more.ππ
Follow me on LinkedIn to see interesting posts like this : ) Linkedin






