Render Terraform's Expressions and Functions locally without any hassle.
This application runs in the background and watches for changes in the file tfcoding.tf
, once this file is modified its Local Values are automatically rendered to the terminal's output (stdout).
This is especially useful for learning about Expressions and Functions that you are not familiar with, while avoiding the whole shebang of terraform init, plan and apply. The goal here is to "compile Terraform" locally to speed up the development (and learning) process.
-
(Optional) Docker Compose
-
Windows
-
Chocolatey Windows Package Manager
IMPORTANT: Open a PowerShell terminal as Administrator
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
-
Install requirements
IMPORTANT: Open a PowerShell terminal as Administrator
choco install -y make
-
macOS:
- Homebrew macOS Package Manager
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install requirements
brew install make
- Homebrew macOS Package Manager
- Clone this repo
git clone https://github.com/unfor19/tfcoding.git
- From now on your working direcotry should be
tfcoding
cd tfcoding
- Render examples/basic/tfcoding.tf - Make changes in that file, like checking new Terraform Expressions
make run
- Clean resources - Removes
tfcoding
containermake clean
This project uses localstack, which means you can provision the AWS core resources, see examples/mock-aws/.
-
Clone this repo
git clone https://github.com/unfor19/tfcoding.git
-
From now on your working direcotry should be
tfcoding
cd tfcoding
-
Render examples/mock-aws/tfcoding.tf - Make changes in that file, like changing the CIDR of subnets
make up-aws
-
Execute
terraform destroy
on changingtfcoding.tf
, add the Local Valueterraform_destroy = true
. For example:// After "destroying" the infra, comment out this variable to execute `terraform apply` locals { terraform_destroy = true }
-
Clean resources - Removes
tfcoding
andlocalstack
containersmake clean-all
make help
With Docker:
docker run --rm -it unfor19/tfcoding --help
Usage: bash entrypoint.sh -r basic/exmaples --watching -o private_subnets
--src_dir_relative_path | -r [REQUIRED] Relative path to the dir that contains tfcoding.tf
--single_value_output | -o [all] Render a single local variable
--src_dir_root | -s [/src] Source root dir in container
--logging | -l [true] Show logging messages
--debug | -d [false] Print verbose output
--watching | -w [FLAG] Auto-render tfcoding.tf on change
--mock_aws | -aws [FLAG] Use this flag for communicating with Localstack
Created and maintained by Meir Gabay
This project is licensed under the MIT License - see the LICENSE file for details