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

Add region_from_zone provider function #17544

Conversation

modular-magician
Copy link
Collaborator

Implement a provider function that lets users get the region from a zone, e.g. get “us-central1” from “us-central1-a”.

We need to decide how the function responds to ‘bad' input and document this in automated tests.

Examples of bad input:

  • empty string

  • string of an inappropriate string like “foobar”

  • string of a region, when a zone is expected

Acceptance Criteria

  • Provider function is implemented
  • Unit tests cover the function’s logic
  • Appropriate levels of acceptance tests added
  • Copy for documentation created

Release Note Template for Downstream PRs (will be copied)

provider: added provider-defined function `region_from_zone` for retrieving the region from a resource's location/zone

Derived from GoogleCloudPlatform/magic-modules#10073

* add regionFromZone function logic

* add region_from_zone_test.go

* add region_from_zone_internal_test.go

* add region_from_zone.html.markdown

* get region_from_zone_test.go passing

* fix region_from_zone_internal_test.go tests

* shorten test config setup time

* have more explicit error for invalid input

* Update mmv1/third_party/terraform/functions/region_from_zone.go

Co-authored-by: Sarah French <[email protected]>

* use compute_disk for better test time

* Update mmv1/third_party/terraform/website/docs/functions/region_from_zone.html.markdown

Co-authored-by: Sarah French <[email protected]>

* Update mmv1/third_party/terraform/functions/region_from_zone_test.go

* Add `location_from_id` provider-defined function (hashicorp#10061)

* Add `location_from_id` function, tests, docs

* Fix whitespace in acc test HCL config

* fix runtime error and update internal test output

* Update mmv1/third_party/terraform/functions/region_from_zone_test.go

Co-authored-by: Sarah French <[email protected]>

* update to use projectRegionRegex

* Update mmv1/third_party/terraform/functions/region_from_zone.go

---------

Co-authored-by: Sarah French <[email protected]>

[upstream:5e798accff1df8b4964e5e52ba668b5dc3ac0c4f]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician merged commit 63d6990 into hashicorp:FEATURE-BRANCH-provider-functions Mar 11, 2024
3 checks passed
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2024
@modular-magician modular-magician deleted the downstream-pr-5e798accff1df8b4964e5e52ba668b5dc3ac0c4f branch November 16, 2024 23:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant