Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.71 KB

README.md

File metadata and controls

51 lines (38 loc) · 1.71 KB

tf.libsonnet infrastructure-live example

This repository contains an example of how to use Jsonnet and tf.libsonnet to manage a multi-state Terraform project.

This represents a toy example of an AWS stack containing a VPC and MySQL database, that uses a fictional Terraform module to deploy each.

NOTE

The underlying module calls use null_resources to simulate the resources. However, the general pattern should be extensible to real world modules and use cases.

Refer to Comparison to Terraform HCL for the motivating example and a full walkthrough.

Usage

You can generate the Terraform code by using the base Jsonnet tool. To start, install jsonnet and jsonnet-bundler (aka jb):

Once you have jsonnet and jb installed, generate the code with the following commands:

$ jb install
$ jsonnet -J ./vendor -c -m out/ main.jsonnet

This will output all the Terraform code to the out directory, resulting in the following folder structure:

./out
├── prod
│   ├── mysql
│   │   └── main.tf.json
│   └── vpc
│       └── main.tf.json
└── stage
    ├── mysql
    │   └── main.tf.json
    └── vpc
        └── main.tf.json

Support

If you have any questions about how to use the tf.libsonnet libraries, ask in the Organization GitHub Discussion.