hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.32k stars 1.73k forks source link

google_privileged_access_manager_entitlement resource creation fails #19659

Closed villekr closed 1 week ago

villekr commented 2 weeks ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.9.6 on darwin_arm64

Affected Resource(s)

google_privileged_access_manager_entitlement

Terraform Configuration

resource "google_privileged_access_manager_entitlement" "my_entitlement" {
  entitlement_id       = "entitlement-test"
  location             = "global"
  max_request_duration = "7200s"
  parent               = var.parent
  requester_justification_config {
    unstructured {}
  }
  eligible_users {
    principals = var.principals
  }
  privileged_access {
    gcp_iam_access {
      role_bindings {
        role = "roles/storage.admin"
      }
      resource      = "//cloudresourcemanager.googleapis.com/projects/${var.project_id}"
      resource_type = "cloudresourcemanager.googleapis.com/Project"
    }
  }
  approval_workflow {
    manual_approvals {
      require_approver_justification = true
      steps {
        approvals_needed = 1
        approvers {
          principals = var.approver_principals
        }
      }
    }
  }
}

Debug Output

https://gist.github.com/villekr/aaacbb8d38d67e58d6ea258c31c3cae4

Expected Behavior

GCP Priviledged Access Manager Entitlement should be created

Actual Behavior

Terraform apply gives an error:

β”‚ Error: Error creating Entitlement: googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
β”‚ <html lang=en>
β”‚   <meta charset=utf-8>
β”‚   <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
β”‚   <title>Error 404 (Not Found)!!1</title>
β”‚   <style>
β”‚     *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
β”‚   </style>
β”‚   <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
β”‚   <p><b>404.</b> <ins>That’s an error.</ins>
β”‚   <p>The requested URL <code>/v1/folder/**************/locations/global/entitlements?alt=json&amp;entitlementId=entitlement-test</code> was not found on this server.  <ins>That’s all we know.</ins>
β”‚
β”‚
β”‚   with google_privileged_access_manager_entitlement.my_entitlement,
β”‚   on main.tf line 6, in resource "google_privileged_access_manager_entitlement" "my_entitlement":
β”‚    6: resource "google_privileged_access_manager_entitlement" "my_entitlement" {

Steps to reproduce

  1. terraform apply

Important Factoids

I'm able to create entitlement from to exact same project:

But not with terraform.

References

No response

slevenick commented 2 weeks ago

Looks like an issue with the parent variable. The request seems to be going to /v1/folder/... but it should be going to /v1/folder**s**/. I think you can just change the parent to include this s and I would guess it would work.

slevenick commented 2 weeks ago

@villekr can you try adding the s to folder and see if it works?

villekr commented 1 week ago

Yep, that was it. Silly mistake, thanks for pointing that out.