Terraform commands can be run via self-hosted Web
491
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:
5000:5000 when running the container to
to enable access from host. In kubernetes, define appropriate Service typesVolumes:
/terrasrc. Hence this could be mounted in
volumes as $HOME/terraform/src:/terrasrcCommands:
terraform initterraform plan --auto-approveterraform apply --auto-approveNote: 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
Content type
Image
Digest
sha256:333c21aac…
Size
72 MB
Last updated
almost 3 years ago
docker pull manjurn/terra-cloud