Ajay k
Ajay k

Reputation: 201

terraform to use different provider for one resource block

We are using hashicorp/google provider @3.90.0 version but for one specific resource we want to use hashicorp/google provider @4.31.0 and continue using @3.90.0 everywhere else. Is there a way to use different provider version for just one block:

as of now provider.tf:

terraform {
  required_version = ">= 0.13.0"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = ">= 3.45, <= 3.90.0"

    }
  }
}

main.tf here in this block we want to use version 4.31.0 for google provider:

resource "google_storage_bucket" "cdn-bucket" {
  project       = var.project_id
  name          = "cdn-${var.project_id}"
  location      = "US"
  storage_class = "MULTI_REGIONAL"

Upvotes: 0

Views: 1160

Answers (1)

Ajay k
Ajay k

Reputation: 201

There is no way to use multiple versions of the same provider in the same configuration. You will need to either make all of your modules have some provider version they are all mutually compatible with, or to split your configuration into multiple parts so that each part can depend on a different version of the provider and be applied separately.

Upvotes: 1

Related Questions