Skip to content

Add API hub product, with resource ApiHubInstance #12499

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

Merged
merged 8 commits into from
Jan 17, 2025

Conversation

edwinfranciss
Copy link
Contributor

@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
Contributor 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
Contributor 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.

@@ -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
Contributor 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
Contributor 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
Contributor 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have updated the project used in the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline, there were issues when calling the 1P API using the PreConfig option. The tests will be updated once we have the delete functionality for the resource as well.

@github-actions github-actions bot requested a review from roaks3 January 16, 2025 11:06
@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 16, 2025
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 12 files changed, 914 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 10 files changed, 904 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 148 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_apihub_api_hub_instance (0 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_apihub_api_hub_instance" "primary" {
  api_hub_instance_id = # value needed
  config {
    cmek_key_name   = # value needed
    disable_search  = # value needed
    encryption_type = # value needed
    vertex_location = # value needed
  }
  description = # value needed
  labels      = # value needed
  location    = # value needed
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 4447
Passed tests: 4016
Skipped tests: 426
Affected tests: 5

Click here to see the affected service packages

All service packages are affected

Action taken

Found 5 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample
  • TestAccApigeeEnvironment_apigeeEnvironmentUpdateTest
  • TestAccComputeRegionPerInstanceConfig_removeInstanceOnDestroy
  • TestAccDataSourceGoogleGkeHubFeature_basic
  • TestAccEphemeralServiceAccountKey_basic

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccComputeRegionPerInstanceConfig_removeInstanceOnDestroy [Debug log]
TestAccDataSourceGoogleGkeHubFeature_basic [Debug log]

🔴 Tests failed when rerunning REPLAYING mode:
TestAccDataSourceGoogleGkeHubFeature_basic [Error message] [Debug log]

Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made.

Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer.


🔴 Tests failed during RECORDING mode:
TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample [Error message] [Debug log]
TestAccApigeeEnvironment_apigeeEnvironmentUpdateTest [Error message] [Debug log]
TestAccEphemeralServiceAccountKey_basic [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

anoopkverma-google pushed a commit to anoopkverma-google/magic-modules that referenced this pull request Jan 31, 2025
niharika-98 pushed a commit to niharika-98/magic-modules that referenced this pull request Feb 17, 2025
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.

3 participants