Terraform unable to recognize private service access connection for FileStore in Shared VPC

Viewed 103

Terraform is not recognizing "private service access connection" in the host project part of the shared VPC setup. It is complaining on UNSUPPORTED argument : An argument named "connect_mode" is not expected here when trying to create a FileStore instance in the service project.

Terraform Version and Provider Versions:

Terraform v1.0.11
provider.google version = ">= 3.58, <= 4.28.0"
provider.google-beta ">= 3.39.0, <4.0.0"

Terraform Configuration Files

resource "google_filestore_instance" "filestoreinstance" {
  provider                     = google
  name                          = "${module.project.project_name}-filestore-usea4-fstore"
  project                       = module.project.project_id
  zone                           = var.zone
  tier                              = "BASIC_SSD"

  file_shares {
    capacity_gb = 2660
    name        = var.filestore_dir_name
  }
        
networks {
    network            = regex(".*/global/networks/(.*)$", local.vpc)[0]  //This is a shared VPC project name (or) Host Project
    modes              = ["MODE_IPV4"]
    connect_mode       = "PRIVATE_SERVICE_ACCESS"
  }
  
labels = var.labels
depends_on = [
    module.subnets,
    module.project
  ]
}

Expected Behavior

Terraform plan and apply should recognize that there is already a "private service access connection and create a Filestore instance. Actual Behavior

Error: Unsupported argument

  on main.tf line 199, in resource "google_filestore_instance" "ailoyalinstance":
 199:     connect_mode       = "PRIVATE_SERVICE_ACCESS"

Reference Docs:

https://cloud.google.com/filestore/docs/shared-vpc#gcloud-cli_2:~:text=console-,gcloud%20CLI,-gcloud%20filestore%20instances

Note: This works fine with GCloud SDK

1 Answers

The connect_mode argument for that block was added in version 3.84 of the beta for the provider. It is absent from the release notes and CHANGELOG for that version for some reason, but you can see the update in the corresponding PR indicating when and how the feature was added to the beta provider.

Use version >= 3.84 of the google-beta provider with that resource, and the argument will be supported.

Related