Skip to content

terraform - add new role for download via Lit element component #621

@ghchinoy

Description

@ghchinoy

PR #620 introduces a Lit webcomponent for direct asset downloading and utilizes the signed URL for GCS asset access.

@csantos & @awaemmanuel can you review the following and let me know if this is a good course of action.

  1. Service Account Identified: The main.tf file creates a dedicated service account for the application:

    • Terraform resource name: google_service_account.creative_studio
    • Account ID: service-creative-studio
    • The full email will be: service-creative-studio@<YOUR_PROJECT_ID>.iam.gserviceaccount.com
  2. Missing IAM Role: Of the google_project_iam_member resources, the roles/iam.serviceAccountTokenCreator role is not granted to this service account. Without this, the API call to access the GCS asset will fail, and the download will error with "Failed to retrieve signed URL from API.".

  3. Missing Environment Variable: The main.tf file defines a locals block for environment variables. SERVICE_ACCOUNT_EMAIL is not included in this block. The backend code will fail to get the correct service account email to use for signing the URL.

2. main.tf Modifications

Change 1: Add the missing IAM role.

In main.tf, add the following resource block. Potential suggestion, right after the google_project_iam_member.creative_studio_vertex_access resource.

resource "google_project_iam_member" "creative_studio_sa_token_creator" {
  project = var.project_id
  role    = "roles/iam.serviceAccountTokenCreator"
  member  = google_service_account.creative_studio.member
}

Change 2: Add the missing environment variable.

In main.tf, inside the locals block, add the SERVICE_ACCOUNT_EMAIL variable.

locals {
  creative_studio_env_vars = {
    PROJECT_ID          = var.project_id
    LOCATION            = var.region
    SERVICE_ACCOUNT_EMAIL = google_service_account.creative_studio.email # <-- ADD THIS LINE
    MODEL_ID            = var.model_id
    VEO_MODEL_ID        = var.veo_model_id
    # ... keep the rest of the variables
  }
}

Metadata

Metadata

Labels

enhancementNew feature or requestquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions