Terrastorm
A simple cli to help you work with using terraservice layouts for terraform
Terraservice?
- https://www.youtube.com/watch?v=wgzgVm7Sqlk
- https://www.slideshare.net/opencredo/hashidays-london-2017-evolving-your-infrastructure-with-terraform-by-nicki-watt
- https://www.hibri.net/2017/11/13/terraform-for-grownups/
NB Whats important to note is that we have added a layers abstraction. This abstraction allows you to compose infra objects that can then be used by your environments, instead of referencing modules directly.
Example layout
- modules are standard terraform modules
- layers implement modules - they dont store secrets, just compose object representations that can be used by the environments
- environments implement any number of layers - here you configure secrets and variables for the individual environments
Environment - Services
Environments allow us to implement services which are instances of layers with environment specific configuration
- can take secrets
- compose layers
- maintain the remote encrypted s3 state
Layers
Layers allow us to combine a number of modules
- no secrets
- compose modules
Modules
Modules act as normal terraform modules and provide access to the standard concept.
- stnadrad terraform modules
But now you have to go to the production environment and run terraform plan and terraform apply for each of your services this gets repetative
├── environments
│ ├── dev
│ │ ├── iam
│ │ │ ├── README.md
│ │ │ ├── main.tf
│ │ │ ├── secrets.auto.tfvars
│ │ │ └── terraform.tfvars
│ │ └── network
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── secrets.auto.tfvars
│ │ └── terraform.tfvars
│ └── prod
│ ├── iam
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── secrets.auto.tfvars
│ │ └── terraform.tfvars
│ └── network
│ ├── README.md
│ ├── main.tf
│ ├── secrets.auto.tfvars
│ └── terraform.tfvars
├── layers
│ ├── iam
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ └── network
│ ├── README.md
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
└── modules
├── subnets
│ ├── README.md
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
└── vpc
├── README.md
├── main.tf
├── outputs.tf
└── variables.tf
Usage
Modify the makefile so your aws and ti-landscape are mounted to the right places
1. make shell
2. `terrastorm run nonprod init` <-- will init on all the services in nonprod
Story 1 - Setup a new Project
As an infra-op I need to create a new project based on the terraservices pattern So that I can inject sparkles into the lives of our clients
terrastorm setup /path/to/project
- will create a new project based on the template defined in the
.terrastorm.yamltemplates.project=https://github.com/williamtsoi1/terraservices-example.git
Story 2 - See my settings
As an infra-op I want to see my current config settings So that I can check all is well
terrastorm show_config
- will output the current config settings loaded from
~/.terrastorm.yamland the default.terrastorm.yaml
Story 3 - Create a new Terraform Module
As an infra-op I need to create a new segment of infrastructure So that I can inject sparkles into the lives of our clients
terrastorm create module :new_module_name
- will create a new "module" with the appropriate
:name.tf,input.tf,output.tffiles
Story 4 - Create a new Layer
As an infra-op
I need to create a new layer of infrastructure
So that I can compose an infrastructure represenation for use in my environments.
terrastorm create layer :new_module_name
- will create a new "module" with the appropriate
:name.tf,input.tf,output.tffiles
Story 5 - Create a new Environment
As an infra-op I need to create a new environment, optionally excluding or including certain modules So that I can inject goodness into the lives of our clients
terrastorm create environment :new_environment_name
- will create a new environment
Story 6 - Add a new service to an Environment
As an infra-op I need to be able to add a module interface to an environment So that I can make magic happe
terrastorm add service :environment :new_service_name
- will create a new service instance in the environment specified
Story 7 - Run a terraform command in an environment service
As an infra-op I need to run terraform commands on the appropriate environment So that I can make magic happe
terrastorm run :environment :cmd :service_name|all
- environment - staging|production|...
- cmd - fmt|init|plan|apply
- service None|all|:name_of_your_service
Story 8 - Exec and shell command in an environment
As an infra-op I need to run shell commands in the appropriate environment So that I can make magic happe
terrastorm cmd :environment ':cmd'
- environment - staging|production|...
- cmd -
ls -alh|tree . -L 3 - service None|all|:name_of_your_service cmd dev 'ls -alh'
Development
docker build -t terrastorm:latest .
docker run -it --rm \
-v $PWD:/src \
-v /Users/ross/p/ross.crawford/ti-landscape:/terraform \
terrastorm:latest sh
docker run -it --rm \
-v $PWD:/src \
terrastorm:latest sh
Using
docker run -it --rm \
-v $PWD:/src \
-v /path/to/project:/terraform \
rosscdh/terrastorm:latest sh
>> terrastorm setup /terraform
>> ls /tearraform
Metadata
Release files for terrastorm 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| terrastorm-0.0.4.tar.gz | 7.7 kB | Without provenance | Details for terrastorm-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| terrastorm-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for terrastorm-0.0.4-py3-none-any.whl |
Total release size: 15.0 kB
Release files / terrastorm-0.0.4.tar.gz
| Download URL | terrastorm-0.0.4.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0397e4ee5a2e707fd426a21a7120e4ac6c53600b9566a7179307a39c025aaaad
|
|
BLAKE2b-256 checksum How to use checksums |
a8d1057fd90323b76c8da459673ff45d6424bfce3277c38a72a8eedcca9fb07d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / terrastorm-0.0.4-py3-none-any.whl
| Download URL | terrastorm-0.0.4-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b65373e0dd0665b4fdc5f3c963c1b6f33fdfa50cb08bbbba14e1f52e69f67586
|
|
BLAKE2b-256 checksum How to use checksums |
95366269ceab3179e284202cf763fa9c69b8171db1f472081d3648eb680bfcd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for terrastorm 0.0.4
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.