Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version constraint operators on modules aren't working for prereleases #31271

Closed
ofhouse opened this issue Jun 18, 2022 · 3 comments
Closed

Version constraint operators on modules aren't working for prereleases #31271

ofhouse opened this issue Jun 18, 2022 · 3 comments
Labels
bug duplicate issue closed because another issue already tracks this problem

Comments

@ofhouse
Copy link

ofhouse commented Jun 18, 2022

Terraform Version

Terraform v1.2.3

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
}

provider "aws" {
  alias  = "global_region"
  region = "us-east-1"
}


module "tf_next" {
  source  = "milliHQ/next-js/aws"
  version = "~> 1.0.0-canary.2"

  providers = {
    aws.global_region = aws.global_region
  }
}

Expected Behavior

When running terraform init the latest prerelease version of the module (1.0.0-canary.4) should be installed.

Actual Behavior

Initialization failed with the following error message:

Initializing modules...
╷
│ Error: Unresolvable module version constraint
│ 
│ There is no available version of module "registry.terraform.io/milliHQ/next-js/aws"
│ (main.tf:22) which matches the given version constraint. The newest available version
│ is 0.13.2.

Steps to Reproduce

  1. terraform init

Additional Context

We currently publish prerelease versions in the semver version format v1.0.0-canary.x for our module Terraform Next.js for AWS to the public Terraform registry.
While in the prerelease phase we want to give our users the possibility to try out the new version.

We want to update the examples with a version constraint that always installs the latest available prerelease (e.g. ~> 1.0.0-canary.2).
The only other working solution is to use exact version numbers (e.g. 1.0.0-canary.4) in the examples, but this would mean that we have to update the version number in all of our examples for each new prerelease.

References

@jbardin
Copy link
Member

jbardin commented Jun 20, 2022

Hi @ofhouse,

Because pre-release tags do not necessarily follow the normal semver order semantics, and one usually does not desire any pre-releases to be included in a range of semantic versions, they must only be defined with an exact version constraint. You can find this documented under Version Constraint Behavior.

We use GitHub issues for tracking bugs and enhancements, rather than for questions. While we can sometimes help with certain simple problems here, it's better to use the community forum where there are more people ready to help.

Thanks!

@jbardin jbardin closed this as completed Jun 20, 2022
@ofhouse
Copy link
Author

ofhouse commented Jun 20, 2022

@jbardin Thanks for taking the time for the detailed response.
Yes, read over the part that says:

A prerelease version can be selected only by an exact version constraint.

So everything works as it should be from the definition.
What I instead want is that Terraform fully adapts Semver versioning, which is already covered in #17994.
Thanks for clarifying and sorry for the false bug report here.

@crw crw added duplicate issue closed because another issue already tracks this problem and removed new new issue not yet triaged labels Jun 22, 2022
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug duplicate issue closed because another issue already tracks this problem
Projects
None yet
Development

No branches or pull requests

3 participants