Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

fix(terraform): explicitly specify project IDs #218

Merged
merged 2 commits into from
Oct 20, 2021
Merged

fix(terraform): explicitly specify project IDs #218

merged 2 commits into from
Oct 20, 2021

Conversation

ace-n
Copy link
Contributor

@ace-n ace-n commented Oct 20, 2021

Terraform does not necessarily assume project IDs based on which resources and/or provider are used. This sometimes results in incorrect project IDs being used.

The easiest fix for this is to specify project IDs within resources explicitly, as done in this PR.

Note

terraform apply may still be buggy (even on new projects! - cc @grayside) after this PR is merged. However, this PR should not introduce any new bugs.

@ace-n ace-n requested a review from a team as a code owner October 20, 2021 03:14
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 20, 2021
@ace-n ace-n requested a review from grayside October 20, 2021 03:15
Copy link
Collaborator

@grayside grayside left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is the reason we assigned provider generally was to help resources inherit project and region from a central location. I prefer setting project and region explicitly, so I like this direction.

However, if we're switching to this, I would expect to see:

  • Removing project from providers to avoid potential for conflicts/confusion on project config
  • Remove project scoping to providers, in favor of having just google and google-beta working as terraform integration imports

I see this as part of a single change, so I'm flagging this as change requested but perhaps I've misunderstood where you are headed?

@ace-n
Copy link
Contributor Author

ace-n commented Oct 20, 2021

RE resource inheriting - I thought the same, but empirically that inheritance behavior doesn't seem to necessarily be the case.

That said, it also seems like google_project requires a project ID.

Maybe this is a bug in Terraform itself?

@grayside
Copy link
Collaborator

I'm not quite sure I followed, are you saying we need a provider per project?

@ace-n
Copy link
Contributor Author

ace-n commented Oct 20, 2021

@grayside we may not. What I'm saying is that we must specify a project ID on any providers we use, because Terraform requires it.

(We may be able to get away with two providers, but I'd rather keep this PR simple and iterate on that question later.)

@grayside
Copy link
Collaborator

Thanks for clarifying.

@ace-n ace-n merged commit 58b6bf5 into main Oct 20, 2021
@ace-n ace-n deleted the tf-project-id branch November 1, 2021 22:13
@grayside grayside added this to the v0.6.0 milestone Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants