Skip to main content

Terraform Utils

This project provides a helper command intended to be used with terraform and terragrunt for applications hosted on AWS. The utility is available on pypi and requires Python 3.6.1+.

One of the ways terragrunt helps keep infrastructure code DRY is by injecting the remote state configuration to the current module. The tf-util command generates names for the terraform state bucket, object, and lock table based on the protect structure.

# modules/app/main.tf
terraform {
  required_version = ">= 0.12"
  # The configuration for this backend will be filled in by Terragrunt
  backend "s3" {}
}

Project Structure

If you are using terragrunt use two repositories to separate your live configuration from your modules. Here's what the tree structure for the live repo looks like. Within the root there are two files meant for common values and remote state management. The first level of folders correspond to each environment you want to create, i.e dev, qa, and prd. The nested folders represent individual constructs within an environment. The resources within a construct share the same terraform state and are managed together.

.
├── common.tfvars
├── dev
│   ├── app
│   │   └── terragrunt.hcl
│   ├── iam
│   │   └── terragrunt.hcl
│   └── network
│       └── terragrunt.hcl
└── terragrunt.hcl

Example Usage

$ pip install terraform-utils
$ cd path/to/live/repo
# verifiy content of common.tfvars
$ cd dev/network
$ tf-util -c bucket
example-terraformstate-dev-company
$ tf-util -c object
app/terraform.tfstate
$ tf-util -c table
example-terraformlock-dev-company

Code Quality

Run the following commands to analyze the project with sonar.

docker run -d --name sonarqube -p 9000:9000 sonarqube
pip install coverage
nosetests --with-xunit --with-coverage --cover-xml
sonar-scanner -D project.settings=cicd/sonar-project.properties

Metadata

Release files for terraform-utils 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terraform-utils 0.1.3
File Size Uploaded Provenance Actions
terraform-utils-0.1.3.tar.gz 5.4 kB Without provenance Details for terraform-utils-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for terraform-utils 0.1.3
File Interpreter ABI Platform Actions
terraform_utils-0.1.3-py3-none-any.whl Python 3 none any Details for terraform_utils-0.1.3-py3-none-any.whl

Total release size: 13.3 kB

Release files / terraform-utils-0.1.3.tar.gz

Download URL terraform-utils-0.1.3.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2b1feee5d9de63cc996039f3e5314386b6485cf3ad049454474aad9c9a896e6d
BLAKE2b-256 checksum
How to use checksums
4c38e56318ba93647ff8860ea3cf5092a2ca7ea2874cd2c5c34ee5f9609886aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

Release files / terraform_utils-0.1.3-py3-none-any.whl

Download URL terraform_utils-0.1.3-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d32d8c3b8cf433da7047774317cefcb603c886e31563070ccafd15f8bff8571
BLAKE2b-256 checksum
How to use checksums
077ece664a6c1b9cac4e57c41713b4de059169fd2eab44fb8a895a5dc4f24e91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

Security for terraform-utils 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page