Trying to use hashicorp/terraform:light
as my CLI instead of installing everything locally on my computer using docker-compose
.
The following configuration is what I had initially:
# docker-compose.yml
version: "3.7"
services:
terraform:
image: hashicorp/terraform:light
When I run the following command from the official documentation
docker-compose run terraform plan main.tf
I get
stat main.tf: no such file or directory
Since I didn’t copy my templates inside the image, the command is not able to find main.tf
template.
I read https://hub.docker.com/r/hashicorp/terraform
And I don’t see any documentation about it, so I did the following.
# docker-compose.yml
version: "3.7"
services:
terraform:
image: hashicorp/terraform:light
volumes:
- ./terraform:/terraform
Notice that I mounted ./terraform
as /terraform
inside the container.
Now you can the command again with the file path relative to /terraform
.
docker-compose run terraform plan /terraform/main.tf
I am not sure if /terraform
is a folder I should be using for this since there is no documentation about it, but it is working so far.
I hope you find this useful since I didn’t find any docs online at the moment,
The existing problem, using local module references as follow:
module "digitalocean" {
source = "../digitalocean"
}
Causes the following issue:
This module is not yet installed. Run "terraform init" to install all modules
required by this configuration.
I am stuck at this step and would be great if I get any help on it.
Cheers.