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.28k stars 1.72k forks source link

Unable to configure Apigee environment policy #15439

Open mjooz opened 1 year ago

mjooz commented 1 year ago

Community Note

Terraform Version

Terraform v1.3.9 provider registry.terraform.io/hashicorp/google v4.77.0

Affected Resource(s)

Terraform Configuration Files

data "google_iam_policy" "viewer" {
  binding {
    role = "roles/viewer"
    members = [
      "user:jane@example.com",
    ]
  }
}

resource "google_apigee_environment_iam_policy" "policy" {
  org_id = "apigee-org"
  env_id = "dev"
  policy_data = data.google_iam_policy.admin.policy_data
}
Error: Error setting IAM policy for apigee environment "apigee-org/environments/dev": 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/apigee-org/environments/dev:setIamPolicy?alt=json</code> was not found on this server.  <ins>That’s all we know.</ins>

Expected Behavior

IAM policy is configured per example code: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/apigee_environment_iam

Actual Behavior

404 error

Steps to Reproduce

  1. terraform apply

Important Factoids

Trying setIamPolicy method, I noticed the same behaviour. There, reason is bad curl command:

curl --request POST `https://apigee.googleapis.com/v1/organizations/apigee-org/environments/dev%3AgetIamPolicy:setIamPolicy? ...

Note %3AgetIamPolicy in the URL.

edwardmedia commented 1 year ago

b/295153637

xuchenma commented 3 months ago

org_id = "apigee-org" should be org_id = "organizations/apigee-org"

In the curl command, %3A should be :