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

fix: support passing service project number to shared_vpc_access to be tf 0.13 compatible #500

Merged
merged 8 commits into from
Nov 24, 2020

Conversation

umairidris
Copy link
Contributor

Fix #499

@umairidris umairidris requested a review from a team as a code owner November 17, 2020 20:18
@morgante
Copy link
Contributor

@umairidris Would it be possible to use implicitly dependency to solve this instead? I'd rather not be adding more module_depends_on resources now that Terraform 0.13 supports it natively.

@bharathkkb
Copy link
Member

We output project_number as part of core, so if we take that as an input for shared_vpc_access wouldn't that get rid of the need for module_depends_on?

@umairidris
Copy link
Contributor Author

@morgante implicit dependencies don't work as intended due to hashicorp/terraform#26857.

@bharathkkb yes that was one option, but we will need to add a required var for project number which will be a breaking change on shared_vpc_access. Is that ok?

@morgante
Copy link
Contributor

Wouldn't an optional variable be sufficient?

@umairidris
Copy link
Contributor Author

Yes, that would work too though we would have two different paths (one with data source and one without). I can do that for now and we can remove the data source in a future major version.

@umairidris
Copy link
Contributor Author

Or not...

Error: Invalid count argument

  on ../../modules/shared_vpc_access/main.tf line 18, in data "google_project" "service_project":
  18:   count      = var.service_project_number == null ? 1 : 0

The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.

@bharathkkb
Copy link
Member

I think it's okay to have a breaking change with the upcoming v10.0 for shared_vpc_access. It is mostly used as a helper for shared_vpc module but I will defer to @morgante

@morgante
Copy link
Contributor

morgante commented Nov 17, 2020

This submodule is actually used directly frequently as well, so I'd definitely like to avoid a breaking change. More generally, I'd like to avoid forcing customers to think about project number at all. It's a confusing implementation detail of GCP and redundant with project ID.

How about we make a lookup_project_number boolean variable as well (default true)?

@umairidris
Copy link
Contributor Author

umairidris commented Nov 17, 2020

If a v10 release is coming soon I would prefer to remove the data source entirely. It seems Terraform is pushing for data and provider blocks to be in the user's control more and more. In the meantime I have added the extra var.

@morgante
Copy link
Contributor

I'm strongly against any change which forces users to provide their project number. This module is scattered all over and, frankly, is simply shifting the burden of confusion to the user's config and reducing the value of the module.

I also think this error is one we're unlikely to encounter outside project factory, so I'd rather take on a bit more complexity here in exchange for easier interfaces outside the module.

@umairidris
Copy link
Contributor Author

umairidris commented Nov 18, 2020

That's a fair point, chances of this happening outside of PF are lower.

@umairidris umairidris changed the title Add module_depends_on to shared_vpc_access fix: support passing service project number to shared_vpc_access to be tf 0.13 compatible Nov 18, 2020
Copy link
Member

@bharathkkb bharathkkb left a comment

Choose a reason for hiding this comment

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

LGTM
/cc @morgante

modules/shared_vpc_access/README.md Show resolved Hide resolved
@umairidris
Copy link
Contributor Author

@morgante does this look good to you?

@morgante morgante merged commit 825d07b into master Nov 24, 2020
@morgante morgante deleted the vpcaccess13 branch November 24, 2020 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shared_vpc module broken in 0.13
3 participants