• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

yaml

GCP Disks Attach To An Instance

September 15, 2020

Here’s how to display a list the disks attached to an instance.

gcloud compute instances describe instance-name \
--project project-id \
--zone us-central1-c \
--format='yaml(disks[].source)'

gcloud compute instances describe instance-name \ --project project-id \ --zone us-central1-c \ --format='yaml(disks[].source)'

Filed Under: Cloud Tagged With: compute, describe, disks, gcp, instances, list, yaml

YAML & Indentation

January 1, 2019

JSON and YAML are used in AWS CloudFormation. Some people prefer YAML for its simplicity. It’s easy to read and code. However, YAML has its own little quirks. It relies heavily on indentation for its structure. If you don’t use the proper spaces, it will fail. I ran into an issue when I ran CloudFormation in AWS. The example below display the contents of my userdata.

This piece of code will NOT work in CloudFormation.

Fn::Base64: !Sub |
#!/bin/bash -xe
yum update -y
mkdir /data
cd /data
aws s3 cp s3://efs-s3-backup-engine .
sleep 30s
initiate.sh

Fn::Base64: !Sub | #!/bin/bash -xe yum update -y mkdir /data cd /data aws s3 cp s3://efs-s3-backup-engine . sleep 30s initiate.sh

This is valid. It’s all about indentation.

Fn::Base64: !Sub |
  #!/bin/bash -xe
  yum update -y
  mkdir /data
  cd /data
  aws s3 cp s3://efs-s3-backup-engine .
  sleep 30s
  initiate.sh

Fn::Base64: !Sub | #!/bin/bash -xe yum update -y mkdir /data cd /data aws s3 cp s3://efs-s3-backup-engine . sleep 30s initiate.sh

By the way, tabs are to be avoided like the plague.

Filed Under: Cloud Tagged With: aws, cloudformation, yaml

Convert JSON to YAML

January 30, 2018

JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. YAML is a flexible, human readable file format that is ideal for storing object trees. YAML stands for “YAML Ain’t Markup Language”. It is easier to read than JSON, and can contain richer meta data. If you would like to switch formats, for example from JSON to YAML or vice versa, there are numerous website out there that can convert your code from one format to another. Check out this json2yaml converter.

Filed Under: Cloud, Linux Tagged With: json, yaml

  • Home
  • About
  • Archives

Copyright © 2023