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

Invalid folder name for folder-iam. Module example using a folder name but it should be ID #156

Open
snahim-g opened this issue Apr 21, 2022 · 2 comments
Labels
enhancement New feature or request P4 low priority issues triaged Scoped and ready for work

Comments

@snahim-g
Copy link

TL;DR

Using a folder name for the folder-iam module errors out as the folder name is invalie.

Expected behavior

Adding iam roles

Observed behavior

│ Error: Error retrieving IAM policy for folder "folders/xxx-shared-iac": googleapi: Error 400: Request contains an invalid
argument.
│ Details:
│ [
│ {
│ "@type": "type.googleapis.com/google.rpc.DebugInfo",
│ "detail": "[ORIGINAL ERROR] generic::invalid_argument: com.google.apps.framework.request.BadRequestException: Invalid
folder resource name: folders/xxx
│ ]
│ , badRequest

│ with module.iac-folder-iam.google_folder_iam_member.folder_iam_additive["default--roles/resourcemanager.folderEditor--user:[email protected]"],
│ on .terraform/modules/iac-folder-iam/modules/folders_iam/main.tf line 49, in resource "google_folder_iam_member" "folder_iam_additive":
│ 49: resource "google_folder_iam_member" "folder_iam_additive" {

Terraform Configuration

resource "google_folder" "iac_folder" {
  display_name = "${var.shared_folder_name}-iac"
  parent       = google_folder.shared_folder.id
  depends_on   = [google_folder.shared_folder]
}

module "iac-folder-iam" {
  source  = "terraform-google-modules/iam/google//modules/folders_iam"
  folders = ["${var.shared_folder_name}-iac"]

  mode = "additive"

  bindings = var.iac_folder_iam_bindings 

  conditional_bindings = var.iac_folder_conditional_bindings 
  depends_on   = [google_folder.iac_folder]
}

Terraform Version

terraform version
Terraform v1.0.9
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v4.18.0
+ provider registry.terraform.io/hashicorp/google-beta v4.18.0
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/random v3.1.2
+ provider registry.terraform.io/hashicorp/time v0.7.2

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

Additional information

Honestly not sure why my folder name would be used here? Wouldn't GCP require a folder ID?

@snahim-g snahim-g added the bug Something isn't working label Apr 21, 2022
@snahim-g snahim-g changed the title Invalid folder name for folder-iam Invalid folder name for folder-iam. Module example using a folder name but it should be ID Apr 21, 2022
@bharathkkb
Copy link
Member

@snahim-g Thanks for the report. The folder resource "name" output from the folder resource actually has the id and is of form folders/{folder_id}. The module should accept both strings that are just ids or google_folder.iac_folder.name. Let me know if this works.

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_folder#name

@morgante
Copy link
Contributor

@bharathkkb We might want to consider changing the variable to folder_ids. Even though name is the technical definition, it's definitely confusing given the presence of display_name as well.

Changing this to FR.

@morgante morgante added enhancement New feature or request triaged Scoped and ready for work P4 low priority issues and removed bug Something isn't working labels Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P4 low priority issues triaged Scoped and ready for work
Projects
None yet
Development

No branches or pull requests

3 participants