GoogleCloudPlatform / terraform-google-cloud-functions

Deploys Cloud Functions (Gen 2)
https://registry.terraform.io/modules/GoogleCloudPlatform/cloud-functions/google
Apache License 2.0
30 stars 25 forks source link

An argument named "service_account" is not expected here. #134

Open ethanbrown3 opened 1 week ago

ethanbrown3 commented 1 week ago

Since upgrading my module from v0.5.0 to v0.6.0 I'm seeing this error.

│ Error: Unsupported argument
│ 
│   on .terraform/modules/pipeline.stream_producer_function/main.tf line 31, in resource "google_cloudfunctions2_function" "function":
│   31:     service_account       = var.build_service_account
│ 
│ An argument named "service_account" is not expected here.

Here is my template code.

module "stream_producer_function" {
  source = "GoogleCloudPlatform/cloud-functions/google"

  project_id        = var.project_id
  function_name     = "${local.full_app_name}-function"
  function_location = var.region
  runtime           = "python312"
  entrypoint        = "main"
  docker_repository = "projects/${var.project_id}/locations/us-central1/repositories/gcf-artifacts"

  event_trigger = {
    trigger_region        = var.region
    event_type            = "google.cloud.pubsub.topic.v1.messagePublished"
    service_account_email = null
    pubsub_topic          = google_pubsub_topic.producer_trigger_topic.id
    retry_policy          = var.retry_policy
    event_filters         = null
  }

  service_config = var.service_config

  storage_source = {
    bucket = var.bucket_name
    object = google_storage_bucket_object.cf_source_zip_code_object.name
  }

  depends_on = [
    google_storage_bucket_object.cf_source_zip_code_object
  ]

  labels = var.labels
}

https://github.com/GoogleCloudPlatform/terraform-google-cloud-functions/commit/d17cfa7f14bbe31c2ddb6aa882a12a83cee4de56#diff-dc46acf24afd63ef8c556b77c126ccc6e578bc87e3aa09a931f33d9bf2532fbbR31

klapmalt commented 3 days ago

Facing the same issue!

module "cf_my-function" {
  source  = "GoogleCloudPlatform/cloud-functions/google"
  version = "~> 0.6.0"

  # Required variables
  function_name     = "my-function"
  project_id        = var.project_id
  function_location = var.region
  runtime           = "python310"
  entrypoint        = "main"

  storage_source = {
    bucket     = var.source_bucket
    object     = google_storage_bucket_object.code_bucket_obj.name
    generation = null
  }

  service_config = {
    service_account_email = module.sa.email
    available_memory      = "8G"
    available_cpu         = "2000m"
  }

  event_trigger = {
    event_type            = "google.cloud.storage.object.v1.finalized"
    service_account_email = module.sa.email
    retry_policy          = "RETRY_POLICY_DO_NOT_RETRY"
    trigger_region        = var.region
    event_filters = [
      {
        attribute       = "bucket"
        attribute_value = var.target_bucket
      }
    ]
  }
}

Works fine with 0.5.0