Cloud Formation — Helper Scripts

  • cfn-init : will look at metadata and install/configure dependencies (yum, files, etc)
  • cfn-signal : gives signal to the “waiting” cf template ( to proceed .. etc)
  • cfn-get-metadata : to retrieve metadata
  • cfn-hup : detect changes in metadata and action on changes

usually : cfn-init → cfn-signal → cfn-hup
cfn init will go ahead and configure the instance
cfn-signal will let CF template that configuration has been completed


Configured by specifying “config” in metadata section
And triggered at the “user data” section
multiple configs → configsets

  • packages : install list of package
  • groups : user group
  • user : user
  • source : download external file from somewhere else (zip archive in S3, github repository)
  • files : create files on instance OR pull from URL
    *** Sub! function → will substitute the variables dynamically
  • !!! No need to create parent directory before “files” part. “files” will automatically create the directory for you
  • commands : series of command
  • ** !Sub == Fn::Sub

** Tips on “commands”
- commands need “test” to run (inside nested scope)
- depending on test pass or fail → determines if they will run command or not
- USE linux test command
- ex. test ! -e /home/petclinic → Petclinic files does not exists
- ex. test 10 = 10 → is 10 equal 10 ?
- → type in >> echo $? >> to get the boolean value (to get the result, or nothing will pop up )
- concatenated : test 10 = 10; echo $?

after cfn-init finishes it’s job → notifies the cloudformation template
Used with creation Policy

Means it will wait for 5 minutes for the health check !

: looks for metadata change every 15 minutes
need to configure via files1. /etc/cfn/cfn-hup.conf 2. /etc/cfn/hooks.d/cfn-auto-reloader.conf




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Forming a PostgreSQL cluster within Kubernetes

Pycon Namibia 2018

Arrow 101 - Building an Android app using Functional Programming

Creating a Physics Based Character Controller from Scratch in Unity

Celebrate Lunar New Year with Tiger Hunt in DreamsVerse

How many HTTP Status Codes are there?

Top Mistakes That Developers Make

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
June Chung

June Chung

More from Medium

Multi-Cloud Vs. Hybrid Cloud Similarities and Differences — SyncCore Cloud Blog

How Solution Engineers lead Product Discovery for internal tools at Clicampo.

Building a Guild in Modern WoW

What’s an example of a web3 app that exists today?