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

Generate consistent id value for data.google_compute_default_service_account #2615

Closed
wants to merge 1 commit into from
Closed

Conversation

sergei-ivanov
Copy link

Fixes #2611

Sets id field on the data.google_compute_default_service_account to be in the same format as for google_service_account resource.

The pattern is the same as for the name attribute as extracted by Google Cloud SDK:

$ gcloud iam service-accounts describe [email protected] --project=production
displayName: Compute Engine default service account
email: [email protected]
etag: <...>
name: projects/production/serviceAccounts/[email protected]
oauth2ClientId: '<...>'
projectId: production
uniqueId: '<...>'

With this change, data.google_compute_default_service_account.<...>.id can be used to populate google_service_account_iam_member.service_account_id attribute without the need for additional string concatenation.

@ghost ghost added the size/xs label Dec 9, 2018
…ce_account`

Fixes #2611

Sets `id` field on the `data.google_compute_default_service_account` to be in the same format as for `google_service_account` resource.

The pattern is the same as for the `name` attribute as extracted by Google Cloud SDK:
```
$ gcloud iam service-accounts describe [email protected] --project=production
displayName: Compute Engine default service account
email: [email protected]
etag: <...>
name: projects/production/serviceAccounts/[email protected]
oauth2ClientId: '<...>'
projectId: production
uniqueId: '<...>'
```

With this change, `data.google_compute_default_service_account.<...>.id` can be used to populate `google_service_account_iam_member.service_account_id` attribute without the need for additional string concatenation.
@danawillow
Copy link
Contributor

I don't like having people depend on the id field. We specifically don't document its format in order to discourage people from using it, because we'd like the ability to change it without breaking people. As we stand, we do have a major release coming up, and I like the idea of consistency between the resources. However, I think we can have this consistency in a way we both like by having the data source call the service account endpoint after it gets the email of the service account, and then fill out all the same fields that the other service account data source does (the important one being name, which is the fully-qualified name). What do you think?

@sergei-ivanov
Copy link
Author

I provided a lot more details on the linked issue #2611 but the main pain point at the moment is in configuring google_service_account_iam_member and friends. The resulting configuration is not consistent between the default service account and user-defined service accounts. And moreover, I'd argue that IAM config it is the only place where service account id is used (AFAIK). Service account email works just fine elsewhere and is much simpler to deal with.

So in a way the better way to resolve the issue would be to deprecate service_account_id on google_service_account_iam_xxxxx resources and introduce service_account_email instead. The IAM resource would then derive the project information (if needed) from service account email and carry on. Is it what you are suggesting too?

@ghost ghost removed the waiting-response label Dec 13, 2018
@danawillow
Copy link
Contributor

Deprecations are annoying, and calling something id, name, or email can easily be solved with better documentation. Let me come up with a PR real quick to show you that id isn't necessary for that, and then I can come back to my suggestion for this.

@sergei-ivanov
Copy link
Author

There's already an existing issue for documentation: #2180
And like the original submitter I spent a considerable amount of time figuring out what the correct configuration might be.

@sergei-ivanov
Copy link
Author

@danawillow I saw your PR to close off #2180 and I think it is a great improvement on the documentation part. Thank you very much for that!

If the use of id attribute is discouraged, then the only thing that still lacks consistency is data.google_compute_default_service_account, which does not have a name attribute exported. So, instead of changing the format of the id attribute, shall we have a read-only name (and perhaps also display_name for completeness) attribute alongside email? Then it will be possible to refer to data.google_compute_default_service_account.xxx.name and google_service_account.yyy.name in a consistent way.

@danawillow
Copy link
Contributor

You're welcome! I think we should do both of those things- that's what I was trying to get at in my comment above (#2615 (comment))

@danawillow
Copy link
Contributor

@sergei-ivanov were you planning on making the changes to also have name, or did you want someone from our side to do that?

@sergei-ivanov
Copy link
Author

@danawillow I might give it a go, but I am confused about the correct place where I would need to make changes. Do I need to make changes in magic modules here, or in this repository, or in both places?

@ghost ghost removed the waiting-response label Dec 26, 2018
@danawillow
Copy link
Contributor

Here or there is fine. If you do it here, we'll migrate it to magic modules for you (and give you the credit here).

@sergei-ivanov
Copy link
Author

Ok, let me update this PR. Will I need to update the other one ( #2616) against master too?

@danawillow
Copy link
Contributor

We changed last week to only working against master, so probably best to close this one and only use that one, or update the branch on this one to master and close that one.

@sergei-ivanov
Copy link
Author

Ok, I finally have a complete patch that also includes documentation updates. I have just verified it on my test GCP project and everything seems to work a treat. Let me submit it directly into magic modules repo for your review. I am going to close these PRs. Please note that I have also updated the title and the description of the linked bug (although it looks more like a feature request now).

@sergei-ivanov sergei-ivanov deleted the patch-1 branch December 30, 2018 04:43
@sergei-ivanov
Copy link
Author

sergei-ivanov commented Dec 30, 2018

For the reference:
GoogleCloudPlatform/magic-modules#1124

@ghost
Copy link

ghost commented Jan 29, 2019

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 Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants