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 API hub product, with resource ApiHubInstance #12499

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

edwinfranciss
Copy link

@edwinfranciss edwinfranciss commented Dec 5, 2024

This PR creates support for new GCP product API hub - https://cloud.google.com/apigee/docs/apihub/what-is-api-hub
As part of the product, added support for the resource ApiHubInstance (google_apihub_api_hub_instance)

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

`google_apihub_api_hub_instance`

@github-actions github-actions bot requested a review from roaks3 December 5, 2024 13:30
Copy link

github-actions bot commented Dec 5, 2024

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@roaks3, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Dec 5, 2024
Copy link

@roaks3 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

@GoogleCloudPlatform/terraform-team @roaks3 This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but will need some more tests

vars:
instance_id: test-instance
autogen_async: true
exclude_delete: true
Copy link
Contributor

Choose a reason for hiding this comment

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

This is slightly surprising, can the instance not be deleted?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, currently we do not support delete for this resource.

Copy link
Contributor

Choose a reason for hiding this comment

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

So if I'm understanding, only one of these resources can be created per project, it is immutable, and it cannot be deleted, meaning that once an instance is created for a particular project, you can never change it, and you can't touch the Terraform config unless project is changed (because TF will attempt a re-creation, which won't work).

Is this the intended behavior? It seems a little confusing to a user to not be able to adjust their config, so perhaps we want to mention that a new project must be used somewhere in the documentation?

Copy link
Author

Choose a reason for hiding this comment

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

I have updated the description of the resource, mentioning that the resource cannot be deleted/updated as of now.

mmv1/products/apihub/ApiHubInstance.yaml Outdated Show resolved Hide resolved
mmv1/products/apihub/product.yaml Outdated Show resolved Hide resolved
@@ -0,0 +1,8 @@
resource "google_apihub_api_hub_instance" "{{$.PrimaryResourceId}}"{
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need some more tests to check the range of config that can be provided (see https://googlecloudplatform.github.io/magic-modules/test/test/):

  • Since this test should be minimal, is config {} valid?
  • You'll need an "update" test to confirm fields that are mutable can be updated in-place, like description and config
  • You'll need to use each field in at least one test (you can do this with the update test, or add an explicit *_full.tf.tmpl example with every possible field specified)

Copy link
Author

Choose a reason for hiding this comment

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

  • config{} wont be valid. One of disable_search or vertex_location would need to be provided. Default value of disable_search would be false. But in that scenario, vertex_location would need to be provided in the config.
  • Currently update is also not supported for this resource
  • Currently only one resource/project can be provisioned. And since delete and update is not supported for this resource, was not able to add further test in the same flow. Do you have any suggestions for this scenario.

Copy link
Author

Choose a reason for hiding this comment

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

I have added a test with all possible fields, which will be provisioned in a separate project. Hope that is fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

For both tests, could you create a separate project for the instance? Otherwise our test environments will become polluted in a way we seemingly cannot clean up. Ie.:

resource "google_project" "project" {
  name       = "{{index $.Vars "project_id"}}"
  project_id = "{{index $.Vars "project_id"}}"
  org_id     = "{{index $.TestEnvVars "org_id"}}"
  deletion_policy = "DELETE"
}

And in the examples blocks:

    vars:
      project_id: 'apihub-proj'
    test_env_vars:
      org_id: 'ORG_ID'

Copy link
Author

Choose a reason for hiding this comment

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

As discussed offline, currently using exclude_test. Have created a separate bug and once one of the pre-requisite bug is competed, will remove this flag.

Copy link

@roaks3 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

github-actions bot commented Jan 9, 2025

@edwinfranciss, this PR is waiting for action from you. If no action is taken, this PR will be closed in 28 days.

Please address any comments or change requests, or re-request review from a core reviewer if no action is required.

Image showing the re-request review button

This notification can be disabled with the disable-automatic-closure label.

Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

One nit, and I'd be curious if you have any more detail regarding the PreConfig option, but otherwise LGTM

@@ -0,0 +1,15 @@
resource "google_apihub_api_hub_instance" "{{$.PrimaryResourceId}}"{
project = "ah-terraform-provider-1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: You are excluding this test, but it will still show up as an example in the documentation. We may want to tweak this just for clarity to something like my-project here and in cmek_key_name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-approval Pull requests that need reviewer's approval to run presubmit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants