Skip to content

terraform init does not recognize the most recent version of a registry.terraform.io hosted module #36674

Closed
@jwadolowski

Description

@jwadolowski

Terraform Version

Terraform v1.11.1
on linux_arm64

Terraform Configuration Files

N/A

Debug Output

$ docker run -it -w /workspace -v ${PWD}/main.tf:/workspace/main.tf -e TF_LOG=DEBUG hashicorp/terraform:1.11.1 init
2025-03-11T14:48:59.651Z [INFO]  Terraform version: 1.11.1
2025-03-11T14:48:59.651Z [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2025-03-11T14:48:59.651Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2025-03-11T14:48:59.651Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-03-11T14:48:59.651Z [DEBUG] using github.com/zclconf/go-cty v1.16.0
2025-03-11T14:48:59.651Z [INFO]  Go runtime version: go1.23.3
2025-03-11T14:48:59.651Z [INFO]  CLI args: []string{"/bin/terraform", "init"}
2025-03-11T14:48:59.651Z [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2025-03-11T14:48:59.651Z [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2025-03-11T14:48:59.651Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2025-03-11T14:48:59.651Z [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2025-03-11T14:48:59.651Z [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2025-03-11T14:48:59.651Z [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2025-03-11T14:48:59.651Z [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2025-03-11T14:48:59.651Z [INFO]  CLI command args: []string{"init"}
Initializing the backend...
2025-03-11T14:48:59.652Z [DEBUG] checking for provisioner in "."
2025-03-11T14:48:59.653Z [DEBUG] checking for provisioner in "/bin"
Initializing modules...
2025-03-11T14:48:59.654Z [DEBUG] Module installer: begin cloudfront-s3-cdn
2025-03-11T14:48:59.654Z [DEBUG] cloudfront-s3-cdn listing available versions of registry.terraform.io/cloudposse/cloudfront-s3-cdn/aws at registry.terraform.io
2025-03-11T14:48:59.654Z [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2025-03-11T14:48:59.698Z [DEBUG] fetching module versions from "https://registry.terraform.io/v1/modules/cloudposse/cloudfront-s3-cdn/aws/versions"
2025-03-11T14:48:59.698Z [DEBUG] GET https://registry.terraform.io/v1/modules/cloudposse/cloudfront-s3-cdn/aws/versions
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.1.0" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.1.1" for cloudposse/cloudfront-s3-cdn/aws
...
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.93.0" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.93.1" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.94.0" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.95.0" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.95.1" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.96.0" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.96.1" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:48:59.830Z [DEBUG] found available version "0.96.2" for cloudposse/cloudfront-s3-cdn/aws

│ Error: Unresolvable module version constraint

│   on main.tf line 1:
│    1: module "cloudfront-s3-cdn" {

│ There is no available version of module "registry.terraform.io/cloudposse/cloudfront-s3-cdn/aws" (main.tf:1) which matches the given version constraint. The newest available version is
│ 0.96.2.

Expected Behavior

At the time of writing, 0.97.0 is the most recent version of the cloudposse/cloudfront-s3-cdn/aws module, therefore it should be downloaded.

Actual Behavior

Terraform 1.11.1 claims the latest available version of the cloudposse/cloudfront-s3-cdn/aws module is 0.96.2, while both 1.11.0 and 1.10.5 correctly recognize 0.97.0 as the most recent one.

Steps to Reproduce

  1. Create main.tf
module "cloudfront-s3-cdn" {
  source  = "cloudposse/cloudfront-s3-cdn/aws"
  version = "0.97.0"
}
  1. Use Terrafrom 1.11.1 to init the working directory
$ docker run -it -w /workspace -v ${PWD}/main.tf:/workspace/main.tf -e TF_LOG=DEBUG hashicorp/terraform:1.11.1 init
2025-03-11T14:55:25.426Z [INFO]  Terraform version: 1.11.1
...
2025-03-11T14:55:25.592Z [DEBUG] found available version "0.96.0" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:55:25.592Z [DEBUG] found available version "0.96.1" for cloudposse/cloudfront-s3-cdn/aws
2025-03-11T14:55:25.592Z [DEBUG] found available version "0.96.2" for cloudposse/cloudfront-s3-cdn/aws

│ Error: Unresolvable module version constraint

│   on main.tf line 1:
│    1: module "cloudfront-s3-cdn" {

│ There is no available version of module "registry.terraform.io/cloudposse/cloudfront-s3-cdn/aws" (main.tf:1) which matches the given version constraint. The newest available version is
│ 0.96.2.
  1. Do the same using 1.11.0
$ docker run -it -w /workspace -v ${PWD}/main.tf:/workspace/main.tf hashicorp/terraform:1.11.0 init
Initializing the backend...
Initializing modules...
Downloading registry.terraform.io/cloudposse/cloudfront-s3-cdn/aws 0.97.0 for cloudfront-s3-cdn...
- cloudfront-s3-cdn in .terraform/modules/cloudfront-s3-cdn
...
Downloading registry.terraform.io/cloudposse/label/null 0.25.0 for cloudfront-s3-cdn.this...
- cloudfront-s3-cdn.this in .terraform/modules/cloudfront-s3-cdn.this
Initializing provider plugins...
- Finding hashicorp/random versions matching ">= 2.2.0"...
- Finding hashicorp/time versions matching ">= 0.7.0"...
- Finding hashicorp/aws versions matching ">= 2.0.0, >= 4.9.0"...
- Finding hashicorp/local versions matching ">= 1.2.0"...
- Installing hashicorp/random v3.7.1...
- Installed hashicorp/random v3.7.1 (signed by HashiCorp)
- Installing hashicorp/time v0.13.0...
- Installed hashicorp/time v0.13.0 (signed by HashiCorp)
- Installing hashicorp/aws v5.90.1...
- Installed hashicorp/aws v5.90.1 (signed by HashiCorp)
- Installing hashicorp/local v2.5.2...
- Installed hashicorp/local v2.5.2 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
  1. And one more time with 1.10.5
$ docker run -it -w /workspace -v ${PWD}/main.tf:/workspace/main.tf hashicorp/terraform:1.10.5 init
Initializing the backend...
Initializing modules...
Downloading registry.terraform.io/cloudposse/cloudfront-s3-cdn/aws 0.97.0 for cloudfront-s3-cdn...
- cloudfront-s3-cdn in .terraform/modules/cloudfront-s3-cdn
...
Downloading registry.terraform.io/cloudposse/label/null 0.25.0 for cloudfront-s3-cdn.this...
- cloudfront-s3-cdn.this in .terraform/modules/cloudfront-s3-cdn.this
Initializing provider plugins...
- Finding hashicorp/aws versions matching ">= 2.0.0, >= 4.9.0"...
- Finding hashicorp/local versions matching ">= 1.2.0"...
- Finding hashicorp/random versions matching ">= 2.2.0"...
- Finding hashicorp/time versions matching ">= 0.7.0"...
- Installing hashicorp/aws v5.90.1...
- Installed hashicorp/aws v5.90.1 (signed by HashiCorp)
- Installing hashicorp/local v2.5.2...
- Installed hashicorp/local v2.5.2 (signed by HashiCorp)
- Installing hashicorp/random v3.7.1...
- Installed hashicorp/random v3.7.1 (signed by HashiCorp)
- Installing hashicorp/time v0.13.0...
- Installed hashicorp/time v0.13.0 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Additional Context

  1. It seems to be a regression issue introduced in 1.11.1
  2. Version 0.97.0 of the module was released yesterday: https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/releases/tag/v0.97.0
  3. The 0.97.0 does show up in the API response
$ curl -s 'https://registry.terraform.io/v1/modules/cloudposse/cloudfront-s3-cdn/aws/versions' | jq '.modules[0].versions[].version' | tail
"0.92.1"
"0.93.0"
"0.93.1"
"0.94.0"
"0.95.0"
"0.95.1"
"0.96.0"
"0.96.1"
"0.96.2"
"0.97.0"
  1. 0.97.0 (the latest) and 0.96.2 (previous version) look nearly identical from API perspective (all the required fields are present):
# 0.96.2
curl -s 'https://registry.terraform.io/v1/modules/cloudposse/cloudfront-s3-cdn/aws/versions' | jq '.modules[0].versions[] | select(.version == "0.96.2")'

# 0.97.0
curl -s 'https://registry.terraform.io/v1/modules/cloudposse/cloudfront-s3-cdn/aws/versions' | jq '.modules[0].versions[] | select(.version == "0.97.0")'

References

No response

Generative AI / LLM assisted development?

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions