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.google_organization.id returns organization/id instead of just the id #5098

Closed
Nosmoht opened this issue Dec 6, 2019 · 9 comments
Closed
Labels

Comments

@Nosmoht
Copy link

Nosmoht commented Dec 6, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

Affected Resource(s)

  • data.google_organization

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://www.hashicorp.com/security
# If reproducing the bug involves modifying the config file (e.g., apply a config,
# change a value, apply the config again, see the bug) then please include both the
# version of the config before the change, and the version of the config after the change.
provider "google" {
  version = "= 3.1.0"
}

data "google_organization" "test" {
  domain = "example.com" # << please change to an org your account has permissions to
}

output "test" {
  value = data.google_organization.test
}

Debug Output

test = {
  "create_time" = "2019-08-09T12:14:48.112Z"
  ...
  "id" = "organizations/1234567890"
  "name" = "organizations/1234567890"
  ...
}

Panic Output

Expected Behavior

data.google_organization.id should just return the id, not organizations/id.

Actual Behavior

data.google_organization.id returns organization/id.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@ghost ghost added the bug label Dec 6, 2019
@Chupaka
Copy link
Contributor

Chupaka commented Dec 6, 2019

@Nosmoht
Copy link
Author

Nosmoht commented Dec 6, 2019

Wow, that was fast. Anyhow docu just says

The following additional attributes are exported:

id - The Organization ID.
name - The resource name of the Organization in the form organizations/{organization_id}.

https://www.terraform.io/docs/providers/google/d/google_organization.html

@Nosmoht
Copy link
Author

Nosmoht commented Dec 6, 2019

Just for others, my current workaround

org_id  = tonumber(replace(tostring(data.google_organization.company.id), "organizations/", ""))

Would it be possible to note all the resources in the upgrade guide that are affected? Currently i have a lot of # forces replacement in Terraform because of this change.

@Chupaka
Copy link
Contributor

Chupaka commented Dec 6, 2019

I believe, the problem is "id" attribute was not officially exported anywhere with a few exceptions like this one, so it has to be addresses personally.

@Nosmoht
Copy link
Author

Nosmoht commented Dec 11, 2019

Honestly, this has a bigger impact. So far for google_project_service it tells me that replacement while running terraform plan would be forced and results in an error while running terraform apply

terraform plan output

  # module.cicd.google_project_service.container["dev"] must be replaced
-/+ resource "google_project_service" "container" {
      + disable_on_destroy = true
      ~ id                 = "cicd-dev/container.googleapis.com" -> (known after apply)
      ~ project            = "cicd-dev" -> "projects/cicd-dev" # forces replacement
        service            = "container.googleapis.com"

      - timeouts {}
    }

terraform apply output

Error: failed to send enable services request: 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/projects/projects/cicd-dev/services/container.googleapis.com:enable?alt=json&prettyPrint=false</code> was not found on this server.  <ins>That’s all we know.</ins>


  on .terraform/modules/cicd/projects.tf line 37, in resource "google_project_service" "container":
  37: resource "google_project_service" "container" {

@neomantra
Copy link

So I was bit by this... started working on a PR to add org_id and see that this change was committed two days ago

Once this is released, you can use data.google_organization.name.org_id

You can build your own latest with these instructions.

But I'm using @Nosmoht 's snippet for now

@neomantra
Copy link

This org_id commit has landed on v3.2.0

@rileykarson
Copy link
Collaborator

Sorry about the disruption! This and a few resources- particularly, datasources- slipped through the cracks and didn't have a great equivalent. org_id supersedes old uses of id, which held the short-form ID value (012345678910), and id across most resources is expected to hold the long-form value (organizations/012345678910).

I'm closing this out since that's available, if I missed anything or you feel this isn't resolved, feel free to reopen it / comment!

@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 👉 hashibot-feedback@hashicorp.com. 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
Projects
None yet
Development

No branches or pull requests

4 participants