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

data provider google_service_account fails to lookup existing service account due to changes to google_project #5215

Closed
mikhail-khodorovskiy opened this issue Dec 17, 2019 · 4 comments
Assignees

Comments

@mikhail-khodorovskiy
Copy link

mikhail-khodorovskiy commented Dec 17, 2019

Terraform Version

Terraform v0.12.8

  • provider.external v1.2.0
  • provider.google v3.2.0
  • provider.google-beta v3.2.0
  • provider.null v2.1.2
  • provider.random v2.1.2

Affected Resource(s)

  • google_XXXXX

Terraform Configuration Files

data "google_projects" "tools_projects" {
  filter = "labels.environment-name:${var.environment_name} AND labels.purpose:tools"
}

data "google_project" "tools_project" {
  project_id = data.google_projects.tools_projects.projects[0].project_id
}

data "google_service_account" "janus" {
  account_id = "janus-google"
  project    = data.google_project.tools_project.id
}

Note that the project id is now of a format "projects/project-id" which breaks subsequent IAM API call URI constructions in the logs below as used to return just project-id

Debug Output

2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: 2019/12/17 23:02:35 [DEBUG] Google API Request Details:
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: ---[ REQUEST ]---------------------------------------
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: GET /v1/projects/-/serviceAccounts/janus-google@projects/hsq-dev-tools-daf5.iam.gserviceaccount.com?alt=json&prettyPrint=false HTTP/1.1
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: Host: iam.googleapis.com
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: User-Agent: google-api-go-client/0.5 HashiCorp Terraform/0.12.8 (+https://www.terraform.io) Terraform Plugin SDK/1.4.0 terraform-provider-google/3.2.0
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: X-Goog-Api-Client: gl-go/1.11.0 gdcl/20191007
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: Accept-Encoding: gzip
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: 
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: 
2019-12-17T23:02:35.284Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: -----------------------------------------------------
]": visit complete
2019-12-17T23:02:35.406Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: 2019/12/17 23:02:35 [DEBUG] Google API Response Details:
2019-12-17T23:02:35.406Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: ---[ RESPONSE ]--------------------------------------
2019-12-17T23:02:35.406Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: HTTP/2.0 404 Not Found
2019-12-17T23:02:35.406Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: Content-Length: 1686
2019-12-17T23:02:35.406Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000
2019-12-17T23:02:35.406Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: Content-Type: text/html; charset=UTF-8
2019-12-17T23:02:35.406Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: Date: Tue, 17 Dec 2019 23:02:35 GMT
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: Server: ESF
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: X-Content-Type-Options: nosniff
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: X-Frame-Options: SAMEORIGIN
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: X-Xss-Protection: 0
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: 
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: <!DOCTYPE html>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: <html lang=en>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   <meta charset=utf-8>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   <title>Error 404 (Not Found)!!1</title>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   <style>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:     *{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}
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   </style>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   <p><b>404.</b> <ins>That’s an error.</ins>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5:   <p>The requested URL <code>/v1/projects/-/serviceAccounts/janus-google@projects/hsq-dev-tools-daf5.iam.gserviceaccount.com?alt=json&amp;prettyPrint=false</code> was not found on this server.  <ins>That’s all we know.</ins>
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: 
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: -----------------------------------------------------
2019-12-17T23:02:35.407Z [DEBUG] plugin.terraform-provider-google_v3.2.0_x5: 2019/12/17 23:02:35 [WARN] Removing Service Account "projects/-/serviceAccounts/janus-google@projects/hsq-dev-tools-daf5.iam.gserviceaccount.com" because it's gone
2019-12-17T23:02:35.485Z [DEBUG] plugin.terraform-provider-external_v1.2.0_x4: 2019/12/17 23:02:35 [TRACE] JSON output: [123 10 32 32 34 97 99 99 101 115 115 95 112 111 108 105 99 121 95 110 97 109 101 34 58 32 34 110 117 108 108 34 10 125 10]
2019-12-17T23:02:37.505Z [DEBUG] plugin.terraform-provider-external_v1.2.0_x4: 2019/12/17 23:02:37 [TRACE] JSON output: [123 10 32 32 34 102 111 108 100 101 114 95 105 100 34 58 32 34 102 111 108 100 101 114 115 47 56 55 52 55 49 53 52 51 57 54 53 57 34 10 125 10]

Expected Behavior

Service account used to be located in google provider v2.20

Actual Behavior

service account is null

Steps to Reproduce

  1. terraform apply
  • #0000
@mikhail-khodorovskiy mikhail-khodorovskiy changed the title data provider google_service_account fails to lookup existing service account data provider google_service_account fails to lookup existing service account due to changes to google_project Dec 17, 2019
@edwardmedia edwardmedia self-assigned this Dec 18, 2019
@edwardmedia
Copy link
Contributor

@mikhail-khodorovskiy Can you try to use project_id instead of id?

data.google_project.tools_project.id

@mikhail-khodorovskiy
Copy link
Author

Yes, that worked. Thank you!

@ghost ghost removed the waiting-response label Dec 19, 2019
@edwardmedia
Copy link
Contributor

@mikhail-khodorovskiy I am glad the suggestion works for you. I am closing this issue. Thanks

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants