Skip to content

Latest commit

 

History

History
67 lines (47 loc) · 1.74 KB

File metadata and controls

67 lines (47 loc) · 1.74 KB

Use terraform in the devops-toolkit

Terraform document

Some document to help you start with terraform

Run with Docker command

Note

To use the existing container instead of creating one, use docker exec command instead of docker run

docker exec -it my_devops_toolkit /bin/bash

Common Run Modes

For instructions on common run modes, visit DevOps Toolkit Common Run Mode.

Use case 1: Run terraform sample code provided in the container

docker run --rm --network host -it -v ~/.dtc:/dtc tungbq/devops-toolkit:latest
# You now in the container terminal
#  Navigate to Terraform sample
pushd samples/terraform/basic
# Init the terraform
terraform init
# Apply change, select 'yes' to confirm
terraform apply
# Once done, destroy the infra, select 'yes' to confirm
terraform destroy
popd

Use case 2: Clone external code inside container

docker run --rm --network host -it -v ~/.dtc:/dtc tungbq/devops-toolkit:latest
# You now in the container terminal

# Now run your cloned script
# Clone code
mkdir terraform_workspace; cd terraform_workspace
git clone <YOUR-REPO> terraform-examples

cd terraform-examples
# Run terraform here: init-plan-apply,...

Use case 3: Mount external code to container

Clone the code to the host then mount to container

# Given that we have code somewhere in you machine
docker run --rm -v "$(pwd)":/root/terraform_workspace -v ~/.dtc:/dtc --network host -it tungbq/devops-toolkit:latest
# Run the terraform code as usual

Troubleshooting