Could not retrieve the list of available versions for provider hashicorp/aws: no available releases match the given constraints

Hi,

I’m creating below module and getting provider version issue when run terraform init

module "lb_role" {
  source    = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
  version = " 5.5.0 "

 role_name = "${var.resource_prefix}_eks_lb"
 attach_load_balancer_controller_policy = true

  oidc_providers = {
    main = {
      provider_arn               = module.eks_cluster.oidc_provider_arn
      namespace_service_accounts = ["kube-system:aws-load-balancer-controller"]
    }
  }
}
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/aws: no available releases match the given constraints >= 3.13.0, >= 3.56.0, >= 4.0.0, < 4.0.0
╵

and I do see the hashicorp/aws versions are used in the stage in different places.

command terraform providers lists below

Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/aws]
├── provider[registry.terraform.io/hashicorp/kubernetes]
├── provider[registry.terraform.io/hashicorp/helm]
├── module.eks_cluster
│   ├── provider[registry.terraform.io/hashicorp/aws]
│   └── module.eks
│       ├── provider[registry.terraform.io/terraform-aws-modules/http] >= 2.4.1
│       ├── provider[registry.terraform.io/hashicorp/aws] >= 3.56.0
│       ├── provider[registry.terraform.io/hashicorp/local] >= 1.4.0
│       ├── provider[registry.terraform.io/hashicorp/kubernetes] >= 1.11.1
│       ├── provider[registry.terraform.io/hashicorp/cloudinit] >= 2.0.0
│       ├── module.node_groups
│       │   ├── provider[registry.terraform.io/hashicorp/aws] >= 3.56.0
│       │   └── provider[registry.terraform.io/hashicorp/cloudinit] >= 2.0.0
│       └── module.fargate
│           └── provider[registry.terraform.io/hashicorp/aws] >= 3.56.0
├── module.lb_role
│   └── provider[registry.terraform.io/hashicorp/aws] >= 4.0.0
├── module.cloudwatch_logs
│   ├── provider[registry.terraform.io/hashicorp/helm] >= 1.0.0, < 3.0.0
│   ├── provider[registry.terraform.io/hashicorp/kubernetes] >= 1.10.0, < 3.0.0
│   └── provider[registry.terraform.io/hashicorp/aws] >= 3.13.0, < 4.0.0
├── module.instance_role
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.cluster_vpc_network
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.metric_set_table
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.msk_cluster
│   ├── provider[registry.terraform.io/hashicorp/aws]
│   └── module.msk_log_group
│       └── provider[registry.terraform.io/hashicorp/aws]
├── module.condition_table
│   └── provider[registry.terraform.io/hashicorp/aws]
└── module.device_model_table
    └── provider[registry.terraform.io/hashicorp/aws]

Providers required by state:

    provider[registry.terraform.io/hashicorp/aws]

    provider[registry.terraform.io/hashicorp/cloudinit]

    provider[registry.terraform.io/hashicorp/helm]

    provider[registry.terraform.io/hashicorp/kubernetes]

    provider[registry.terraform.io/hashicorp/local]

    provider[registry.terraform.io/terraform-aws-modules/http]

tried with different versions but throws same error, can someone help

thanks!

You asked for a version that was both greater-or-equal to 4.0.0 whilst also being less than the same.

This is a logical impossibility.

Hi @sandhyamudiraj888,

The modules you are using seem to have conflicting compatibility constraints for the hashicorp/aws provider.

Specifically:

  • module.lb_role requires >= 4.0.0
  • module.cloudwatch_logs requires < 4.0.0

Unless you are able to upgrade all of the other modules in your configuration to be compatible with hashicorp/aws v4.x, I think the answer here will be to select an older version of terraform-aws-modules/iam/aws that is compatible with hashicorp/aws v3.x, so that it will be compatible with the various existing modules in your configuration.

The changelog for that module package says that its version 5.0.0 is the first one that requires AWS provider 4.0, so one possible approach would be to constrain your module call to only versions earlier than that one:

module "lb_role" {
  source  = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
  version = "< 5.0.0"

  # ...
}

At the time I’m writing this the latest version which meets that constraint is 4.24.1, which declares that it requires hashicorp/aws >= 3.0 and so should be able to select an AWS provider version that is compatible with your other existing modules:

At some later time you will probably want to upgrade to AWS provider v4, but you’ll probably need to upgrade all of your modules together to achieve that, to ensure that they will all be compatible with v4 together: some of your modules are explicitly declaring that they are not compatible with v4, so you won’t be able to upgrade to that new provider version until you can upgrade to a newer version of the module which is compatible with the new provider.

Hi @apparentlymart I also have the same problem but it looks like this

Could not retrieve the list of available versions for provider
hashicorp/google-beta: no available releases match the given constraints ~>
4.26.0, ~> 4.37.0, != 4.53.0

I don’t really get why this is an error. Any version >= 4.37 and not 4.53 should be fine but it says no available versions.

Please refer to the docs to check what the ~> operator actually does - it’s not how you’re interpreting it.

You have told Terraform to find you a version which is, simultaneously:

  • 4.26.something (and not 4.27 or later)
  • 4.37.something (and not 4.38 or later)

It’s clearly impossible to satisfy both of these bullet points at the same time with the same version, which is why you receive an error.

Oh yes you’re right, it should have been ~4.0, != 4.53.0

Thank you