Some document to help you start with terraform
- https://developer.hashicorp.com/terraform
- https://github.com/tungbq/devops-basic/tree/main/topics/terraform
Navigate to your workspace folder, then run:
devops-toolkit-cli init demo_terraform01
devops-toolkit-cli run demo_terraform01
# You now in the container terminal. Execute the terraform command normally
terraform --version
It will mount the workspace code to container and you then can execute desired scripts inside the devops-toolkit
container
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
For instructions on common run modes, visit DevOps Toolkit Common Run Mode.
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
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,...
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
- For any issues, check this reference