To integrate with Docker, I've setup my terraform as follows:
The required provider:
docker = {
source = "kreuzwerker/docker"
version = "2.11.0"
}
the instantiation of that provider:
provider "docker" {
}
And finally I use it as follows in a resource:
data "docker_registry_image" "myapp" {
name = some_image_url
}
When I run terraform init
, it seems it is still referring to the "old" terraform provider by HashiCorp:
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/random versions matching "3.0.1"...
- Finding hashicorp/null versions matching "~> 3.0.0"...
- Finding hashicorp/external versions matching "~> 2.0.0"...
- Finding kreuzwerker/docker versions matching "2.11.0"...
- Finding latest version of hashicorp/docker...
- Finding hashicorp/google versions matching "~> 3.56.0"...
- Finding hashicorp/azurerm versions matching "~> 2.46.1"...
- Installing hashicorp/null v3.0.0...
- Installed hashicorp/null v3.0.0 (signed by HashiCorp)
- Installing hashicorp/external v2.0.0...
- Installed hashicorp/external v2.0.0 (signed by HashiCorp)
- Installing kreuzwerker/docker v2.11.0...
- Installed kreuzwerker/docker v2.11.0 (self-signed, key ID 24E54F214569A8A5)
- Installing hashicorp/google v3.56.0...
- Installed hashicorp/google v3.56.0 (signed by HashiCorp)
- Installing hashicorp/azurerm v2.46.1...
- Installed hashicorp/azurerm v2.46.1 (signed by HashiCorp)
- Installing hashicorp/random v3.0.1...
- Installed hashicorp/random v3.0.1 (signed by HashiCorp)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/docker: provider registry registry.terraform.io does not have a
provider named registry.terraform.io/hashicorp/docker
If you have just upgraded directly from Terraform v0.12 to Terraform v0.14
then please upgrade to Terraform v0.13 first and follow the upgrade guide for
that release, which might help you address this problem.
Did you intend to use kreuzwerker/docker? If so, you must specify that source
address in each module which requires that provider. To see which modules are
currently depending on hashicorp/docker, run the following command:
terraform providers
When I run terraform providers
I indeed see the reference, caused by docker_registry_image
:
...
├── provider[registry.terraform.io/hashicorp/docker]
...
Notes:
How can I solve this? Thanks!
It seems like we didn't migrate correctly.
I've solved it by setting my terrorm version back to 0.13
and running terraform 0.13upgrade
. After the command executed I upgraded to 0.14.6
again and all worked.
source: https://www.terraform.io/docs/cli/commands/0.13upgrade.html
What did the command do?
This created a file in my module folder (where I use a docker resource) called versions.tf
with the following contents:
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
}
google = {
source = "hashicorp/google"
}
random = {
source = "hashicorp/random"
}
}
required_version = ">= 0.13"
}
Note that what is created here will depend on your specific situation.
It also created a file in my working directory that contained:
terraform {
required_version = ">= 0.13"
}
(The providers were in a different file and already had the correct docker source, hence only the required version addition was added to the new file.)