Terraform image installing v 0.11, but wanted v .012

I am using terraform in an EC2 instance using terraform image by using below code.

image:
name: hashicorp/terraform:light

entrypoint:
- ‘/usr/bin/env’
- ‘PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin’

It installs the terraform v 0.11. But i wanted to install v 0.12 using the terraform image. Is there any way where i can specify the terraform v .012 version using the terraform image.

Hi @VarunBhaskara,

I’m not sure exactly what is going on here but a tricky thing about the mutable tags like “light” and “latest” is that once you have a reference to those tags on your local Docker daemon you may end up using the cached version of that tag rather than the latest from upstream, depending on how exactly you’re interacting with Docker.

I’d recommend instead using a specific version tag, since those allow you to be explicit about which version you want to use and those tags are immutable once published so this local caching behavior isn’t a concern.

For example, you can get the latest Terraform version at the time of writing by using hashicorp/terraform:0.12.23 instead of hashicorp/terraform:light.

Hi @apparentlymart

I have changed to the way how you have suggested. Still it is downloading version 11 only. Below is the code i have used.

image:
name: hashicorp/terraform:0.12.23
entrypoint:

  • ‘/usr/bin/env’
  • ‘PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin’

Below is the message that it prints.

No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted.
Successfully extracted cache.

I am using custom git lab runner which is an EC2 instance to run the code.

Regards,
Varun.

Hi @VarunBhaskara,

Unfortunately I’m not sure what is going on here. I wonder if the GitLab feature that is running Docker for you here is using it in a different way than I’m accustomed to when using the docker CLI directly, and maybe it requires specifying the image reference in a different way.

Perhaps you could experiment with running the docker run CLI command locally first to get familiar with how the images behave, and then try to figure out how to translate what you got working with the CLI to work inside GitLab.