Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tag_binding_values not working in "terraform-google-modules/project-factory/google" #929

Open
marce1990 opened this issue Aug 6, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@marce1990
Copy link

TL;DR

When adding the variable "tag_binding_values" a list of strings (example - ["test"]) is returning an error:
Error: Error creating TagBinding: googleapi: Error 400: com.google.apps.framework.request.StatusException: generic::INVALID_ARGUMENT: Invalid CRM resource name

Expected behavior

Expected behavior is to create the tags to the project but is returning an error, maybe is not documented how to use it properly

Observed behavior

module.avm-project.module.project-factory.google_tags_tag_binding.bindings["test"]: Creating...

│ Error: Error creating TagBinding: googleapi: Error 400: com.google.apps.framework.request.StatusException: generic::INVALID_ARGUMENT: Invalid CRM resource name: 'tagValues/test'.

│ with module.avm-project.module.project-factory.google_tags_tag_binding.bindings["test"],
│ on .terraform/modules/avm-project/modules/core_project_factory/main.tf line 386, in resource "google_tags_tag_binding" "bindings":
│ 386: resource "google_tags_tag_binding" "bindings" {

Terraform Configuration

terraform {
  required_version = ">=0.13.0"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 5.36"
    }
  }
  backend "gcs" {}
}

Terraform Version

Terraform v1.4.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v5.38.0
+ provider registry.terraform.io/hashicorp/google-beta v5.38.0
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/random v3.6.2
+ provider registry.terraform.io/hashicorp/time v0.11.2

Additional information

No response

@marce1990 marce1990 added the bug Something isn't working label Aug 6, 2024
@bharathkkb
Copy link
Member

Hi @marce1990 could you provide your configuration where you are passing in the tag value? tagValues/test seems like a potentially invalid value. It should be using the numeric generated name from this computed field https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/tags_tag_value#name

@marce1990
Copy link
Author

Hi @bharathkkb thanks for the answer, if I use the resources provided by terraform: resource "google_tags_tag_key" + resource "google_tags_tag_value" I'm sure it will work.

What I'm trying to use is the tag option in the module "terraform-google-modules/project-factory/google", that if I'm not wrong there is an example of how to use it here: https://github.com/terraform-google-modules/terraform-google-project-factory/blob/master/examples/tags_project/README.md#project-with-tags

The problem is when I replicate what I see in the main.tf example: https://github.com/terraform-google-modules/terraform-google-project-factory/blob/master/examples/tags_project/main.tf

I'm suppose to add this line to the module:

module "project-factory" {
  source  = "terraform-google-modules/project-factory/google"
  version = "~> 15.0"

  random_project_id       = true
  name                    = "simple-tag-project"
  org_id                  = var.organization_id
  folder_id               = var.folder_id
  billing_account         = var.billing_account
  default_service_account = "deprivilege"
  tag_binding_values      = [var.tag_value]
}

But when I do this, is not working, whatever you write in the tag_value variable, that is supposed to be a string value:

variable "tag_value" {
  description = "value"
  type        = string
}

I just copy and paste here:

image

Once you perform a terraform plan this is how it looks like:

image

And then when you launch the terraform apply (in this case I wrote "testvalue" but same error):

image

So maybe I'm not doing it right and I should provide a different input to the tag variable, but I tried many and none of them are working.

Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Oct 18, 2024
@marce1990
Copy link
Author

The problem is still there, this is not working as I think it should work. Just commenting to avoid this issue to be closed in 7 days. Thanks!

@github-actions github-actions bot removed the Stale label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants