Skip to main content

Use Terrastorm on Terraservices layout for terraform

Project description

Terrastorm

A simple cli to help you work with using terraservice layouts for terraform

Terraservice?

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

  1. modules are standard terraform modules
  2. layers implement modules - they dont store secrets, just compose object representations that can be used by the environments
  3. 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

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.yaml and 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.tf files

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.tf files

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

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

terrastorm-0.0.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

terrastorm-0.0.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file terrastorm-0.0.3.tar.gz.

File metadata

  • Download URL: terrastorm-0.0.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for terrastorm-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d97029ec00e9e23f05e7ae4fee03c237920c52e2b86f30cdd4bd84b4c04e5230
MD5 d1d8da8ae1bd94394919971284fe9204
BLAKE2b-256 8b17e666443abe08768da89adc38a6bbfe8019e417e37ee1f58c46876039dd86

See more details on using hashes here.

File details

Details for the file terrastorm-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: terrastorm-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for terrastorm-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 facb1a6e85aaf4e403e9bdf517f1e6680050908076e82e72400c100a087c6593
MD5 b3f7d47d5032f78de0d5522782dfaf32
BLAKE2b-256 fa3b0f5c96f93a5f54bc26ca2270e2e54c0e0a089ed3fa258980bc2382fb6813

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page