Askar
Askar

Reputation: 523

Terraform init reports Failed to query provider packages via Github Actions

Dunno what is going on and need your help. It works doing locally but via pipeline I keep getting issue on retrieving provider packages.

My github configuration:

- name: Setup Terraform
        uses: hashicorp/setup-terraform@v1
        with:
          terraform_version: 0.15.5
          cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

      # Write the gcp credentials to a temp file
      - name: Setup Creds
        run: |-
            echo ${GCP_CREDS} > gcp_key.json
            cat gcp_key.json
        env: 
            GCP_CREDS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_DEFAULT }}

      # Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
      - name: Terraform Init
        run: terraform init

My provider looks like this:

terraform {
  required_version = ">= 0.15"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "3.71.0"
    }

    google-beta = {
      source  = "hashicorp/google-beta"
      version = "3.71.0"
    }
  }
}

and I keep getting following issue:

enter image description here

Upvotes: 1

Views: 6071

Answers (1)

ydaetskcoR
ydaetskcoR

Reputation: 56967

As mentioned in the comments, your modules have conflicting version constraints.

The error message shows:

Could not retrieve the list of available versions for provider hashicorp/google: no available releases match the given constraints >= 2.12.0, ~> 3.45, ~> 3.53, 3.55.0, 3.71.0, <4.0.0

So you have modules setting each of the following version constraints on the Google provider:

  • >= 2.12.0
  • ~> 3.45
  • ~> 3.53
  • 3.55.0
  • 3.71.0
  • <4.0.0

The conflict arises here because you have a specific version constraint on both 3.55.0 and 3.71.0 which can't then be solved.

You will need to relax the constraint on one of these to allow Terraform to be able to download the appropriate provider version.

Upvotes: 1

Related Questions