-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 support for parameter manager parameter resource google_parameter_manager_parameter
#12630
Add support for parameter manager parameter resource google_parameter_manager_parameter
#12630
Conversation
Hello! I am a robot. Tests will require approval from a repository maintainer to run. @melinath, 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. |
guides: | ||
api: 'https://cloud.google.com/secret-manager/parameter-manager/docs/reference/rest/v1/projects.locations.parameters' | ||
docs: | ||
base_url: 'projects/{{project}}/locations/global/parameters' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will parameters ever be location-based? Or are they strictly limited to global forever?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API is regional and global is considered as a region ( so base URL can be parameterised)
However the URL for global and regional API endpoints vary:
Global: parametermanager.googleapis.com
Regional: parametermanager.**{location}.rep.**googleapis.com
@slevenick Just because of this we will have to make keep regional and global resources. Can these be combined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm, does the regional endpoint work for global? Like parametermanager.**global.rep.**googleapis.com
?
If so, it should be easy to regionalize it now and allow global as a region.
Otherwise it should be possible, but may require some special casing. A lot of it depends on how you want to surface these resources to customers. Should they be separate resources in Terraform or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the regional endpoint work for global? Like parametermanager.**global.rep.**googleapis.com?
- It will not for global only parametermanager.googleapis.com will work
@slevenick Regarding separate resources: Given that we don't have any change in logic, I don't have a strong reason why we should have separate resources apart from segregating the endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do switching of the endpoint based on the value of a location field to combine the resources. We would need to make that decision now though, so we should discuss.
Such an approach would complicate use of custom endpoints for this resource though, so we may need to accommodate that somehow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline we will continue with having separate resources for global and regional Parameters and Parameter Versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the regional variants may need to be handwritten per hashicorp/terraform-provider-google#12738 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making a regional variant product folder might be easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 4379 Click here to see the affected service packages
Action takenFound 9 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: 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: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
/gcbrun |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 4387 Click here to see the affected service packages
Action takenFound 8 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: 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: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 4389 Click here to see the affected service packages
Action takenFound 3 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: 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: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
@slevenick Could you please review this PR? |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 4421 Click here to see the affected service packages
Action takenFound 5 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: 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: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
Assigning a new reviewer, as the original reviewer is OOO |
@modular-magician reassign-reviewer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small questions/changes but overall LGTM
The format type of the parameter resource. Default value is UNFORMATTED. | ||
default_from_api: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this default expected to be stable over time? If so, it would be a slightly better UX to use default_value rather than default_from_api. More info at https://googlecloudplatform.github.io/magic-modules/develop/diffs/#default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this default expected to be stable over time?
What do you think @gptSanyam?
If so, it would be a slightly better UX to use default_value rather than default_from_api. More info at https://googlecloudplatform.github.io/magic-modules/develop/diffs/#default.
However, AFAIK, default values are being sent in the request body itself. So, I think it would be better that the field is optional + computed. @melinath Let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the problem with sending default values in the request body? That is also what happens if a user sets a value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if in future the default from the API side changes than it would require the change to be done in the provider too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, Yeah, I agree with your point that if default from the API is going to stable than we can also use the default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just leave this as default_from_api since the regional variant was already merged with that. For future reference, default_value is preferred where possible for the reasons listed above, but it's not the end of the world to use default_from_api instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @melinath
I can't think of a scenario where the default value will change.
So my recommendation is to change this to default value.
@abheda-crest we will need to fix this in the regional resource as well - which is already merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, SGTM - the other resource was merged on Wednesday so it should still be safe to change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melinath I've used default_value
as UNFORMATTED
instead of default_from_api
for both google_parameter_manager_parameter
and google_parameter_manager_regional_parameter
resource.
func TestAccParameterManagerParameter_import(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), | ||
CheckDestroy: testAccCheckParameterManagerParameterDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccParameterManagerParameter_import(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_parameter.parameter-import", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccParameterManagerParameter_import(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_parameter" "parameter-import" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
format = "YAML" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "val2" | ||
key3 = "val3" | ||
key4 = "val4" | ||
key5 = "val5" | ||
} | ||
} | ||
`, context) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this fully duplicates the generated TestAccParameterManagerParameter_parameterWithLabelsExample
: https://github.com/modular-magician/terraform-provider-google-beta/compare/auto-pr-12630-old..auto-pr-12630#diff-ff73922eed881cfc98b75567279d475bd05f6cd8163cb65d6d07ca6cc86309c1R102
func TestAccParameterManagerParameter_import(t *testing.T) { | |
t.Parallel() | |
context := map[string]interface{}{ | |
"random_suffix": acctest.RandString(t, 10), | |
} | |
acctest.VcrTest(t, resource.TestCase{ | |
PreCheck: func() { acctest.AccTestPreCheck(t) }, | |
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), | |
CheckDestroy: testAccCheckParameterManagerParameterDestroyProducer(t), | |
Steps: []resource.TestStep{ | |
{ | |
Config: testAccParameterManagerParameter_import(context), | |
}, | |
{ | |
ResourceName: "google_parameter_manager_parameter.parameter-import", | |
ImportState: true, | |
ImportStateVerify: true, | |
ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, | |
}, | |
}, | |
}) | |
} | |
func testAccParameterManagerParameter_import(context map[string]interface{}) string { | |
return acctest.Nprintf(` | |
resource "google_parameter_manager_parameter" "parameter-import" { | |
provider = google-beta | |
parameter_id = "tf_test_parameter%{random_suffix}" | |
format = "YAML" | |
labels = { | |
key1 = "val1" | |
key2 = "val2" | |
key3 = "val3" | |
key4 = "val4" | |
key5 = "val5" | |
} | |
} | |
`, context) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
Breaking Change(s) DetectedThe following breaking change(s) were detected within your pull request.
If you believe this detection to be incorrect please raise the concern with your reviewer. |
/gcbrun |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
Breaking Change(s) DetectedThe following breaking change(s) were detected within your pull request.
If you believe this detection to be incorrect please raise the concern with your reviewer. |
Tests analyticsTotal tests: 4425 Click here to see the affected service packages
Action takenFound 8 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: 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: 🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
test failures are unrelated |
Add support for parameter manager parameter resource
google_parameter_manager_parameter
.More info about parameter manager: https://cloud.google.com/secret-manager/parameter-manager/docs/overview
Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.