Skip to main content

Command Palette

Search for a command to run...

CloudFormation and Terraform: Mapping Core Concepts

Leveraging transferable knowledge from CloudFormation to learn a second Infrastructure as Code tool, Terraform

Updated
2 min read
CloudFormation and Terraform: Mapping Core Concepts
B

A fledgling engineer dabbling into areas of DevOps, AWS and automation. I enjoy tinkering with technology frameworks and tools to understand and gain visibility in the underlying mechanisms of the "magic" in them.

In the progress of accumulating nuggets of wisdom in the different software engineering disciplines!

Overview

This article documents the relatable concepts that I find relatable and transferrable based on my experience on CloudFormation to Terraform.

Parent-Child Stack v Modules

Both tools share a similar behavior like a function in a programming language, i.e. taking inputs/parameters to do something.

In CloudFormation, parent-child stack is used when calling multiple different templates. The child stack is also known as nested stack. The nested stack is referencing to a templateUrl which will point to a CloudFormation template residing in a S3 bucket.

In Terraform, you can defined resources within the Terraform configuration files. One can also use modules which is akin to nested stack. The module can point to a local path or remote source, i.e. Terraform, S3 bucket or other version control system repository.

Parameters v Variables

In CloudFormation, you will define parameters which allows user to provide dynamic values when provisioning the resources.

  1. Parameters defined in the parent CloudFormation stack can be passed into the nested stack

  2. Observe that the parameters defined in the parent stack template, is also defined in the child stack template

In Terraform, input variables are defined to allow users to pass values as inputs.

  1. Define the variables that will be used in the module

  2. In the module, pass the values that will be used as input

  3. In the Terraform configuration file(s) defined under the module, the values from the input variables will be used by the Terraform resources

Automation and Tools

Part 3 of 10

Any form of automation, from scripting, utility scripts, IaC and more! Writing them in my own words to (hopefully!) simplify the concepts.

Up next

How to Set Up NSSM Service Using an Idempotent Approach

Testing NSSM removal of service and introduce some consistency when performing mutable deployment