No project description provided
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for terraform_utils-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 294d1676bdbfd074cd89e0211848aed026151aa7e01968fe4cc699b3f0548e1c |
|
MD5 | 4e1adb33738e1aa3fba83a4183194a38 |
|
BLAKE2b-256 | 7801b9cf8700eeace16be596f9a30a162d76138a78897e09d41d1dd305fbae44 |