CloudFormation and Terraform: Mapping Core Concepts
Leveraging transferable knowledge from CloudFormation to learn a second Infrastructure as Code tool, Terraform

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.
Parameters defined in the parent CloudFormation stack can be passed into the nested stack
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.
Define the variables that will be used in the module
In the module, pass the values that will be used as input
In the Terraform configuration file(s) defined under the module, the values from the input variables will be used by the Terraform resources

![[DH] Keeping an organised inventory of annotated screenshots](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1731688657857%2Fcaeeeb6f-1530-4c88-a820-d22deaf0391e.png&w=3840&q=75)



