Sign inSign up

manjurn/terra-cloud

By manjurn

Updated almost 3 years ago

Terraform commands can be run via self-hosted Web

Image
0

491

manjurn/terra-cloud repository overview

Terraform commands can be run via Web

Why the docker for TF? Typically Terraform(TF) code needs a command line to issue TF CLI commands to enable infrastrcuture management. For managing the same server where TF is installed is understandable. However, most of the time TF is being used to manage remote infrstructure. Dedicating a machine or a VM just for TF seems a waste of resources. Hence this repo hosts the TF executable within a docker container. However, as there is no "Server /Service" of TF, executing TF executable from a docker container does not solve the complete problem. The solution is to bundle the TF executable with a Web app/framework like Flask would allow to create simple API which can take "commands" and run the TF executable with corresponding CLI command.

This repo contains a Dockerfile which takes the base image of python, then adds a TF executable from TF image. The simple python programs written with flask framework define endpoints for each of the TF CLI commands. The actual TF files can be mapped to a bind volume and modified / updated

Ports:

  1. The docker default runs on port 5000. Use port mapping 5000:5000 when running the container to to enable access from host. In kubernetes, define appropriate Service types

Volumes:

  1. The TF configuration files (.tf / .json) could be uploaded on the fly using the bind mounts. TF commands are configured to be executed on folder /terrasrc. Hence this could be mounted in volumes as $HOME/terraform/src:/terrasrc

Commands:

  1. https://host:5000/terrainit - Executes terraform init
  2. https://host:5000/terraplan - Executes terraform plan --auto-approve
  3. https://host:5000/terraapply - Executes terraform apply --auto-approve

Note: Auto Aproval option is used in both plan and apply as the web page cannot wait for the prompt to say YES as is normally the case in TF CLI

docker-compose.yaml

services:
  terra-cloud:
    image: manjurn/terra-cloud:latest
    container_name: terra-cloud
    ports:
    - 5000:5000
    volumes:
    - path/to/local/tf/files:/terrasrc

Tag summary

Content type

Image

Digest

sha256:333c21aac

Size

72 MB

Last updated

almost 3 years ago

docker pull manjurn/terra-cloud