terraform-google-gcr-cleaner icon indicating copy to clipboard operation
terraform-google-gcr-cleaner copied to clipboard

Error: no project value set. `project_id` must be set at the resource level, or a default `project` value must be specified on the provider

Open 6aKa opened this issue 1 year ago • 0 comments

TL;DR

locals {
  app_artifact_repo = "test-app-image-repo"
  region            = "europe-west3"
  project_id        = "test"
}

module "gcr-cleaner" {
  source  = "mirakl/gcr-cleaner/google"
  version = "1.3.0"

  gar_repositories = [
    {
      name       = local.app_artifact_repo
      region     = local.region
      project_id = local.project_id
    }
  ]
}

I got error from terraform

│ Error: no project value set. `project_id` must be set at the resource level, or a default `project` value must be specified on the provider
│
│   with module.gcr-cleaner.data.google_project.this,
│   on .terraform/modules/gcr-cleaner/data.tf line 2, in data "google_project" "this":
│    2: data "google_project" "this" {}

and from terragrunt

│ Error: project: required field is not set
│
│   with data.google_project.this,
│   on data.tf line 2, in data "google_project" "this":
│    2: data "google_project" "this" {}

I don't want specify project in the provider configuration, because module use from terragrunt with multiple projects. How I can set project_id on resource level?

Expected behavior

No response

Observed behavior

No response

Terraform Configuration

default

Terraform Version

Terraform v1.2.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/google v4.31.0
+ provider registry.terraform.io/hashicorp/google-beta v4.31.0

Your version of Terraform is out of date! The latest version
is 1.2.6. You can update by downloading from https://www.terraform.io/downloads.html

Additional information

No response

6aKa avatar Aug 03 '22 14:08 6aKa