-
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
Open
abheda-crest
wants to merge
4
commits into
GoogleCloudPlatform:main
Choose a base branch
from
abheda-crest:parameter-manager-parameter-resource-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+334
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ad8658e
Add support for parameter manager parameter resource
abheda-crest e81bbc0
Merge branch 'main' into parameter-manager-parameter-resource-support
abheda-crest ccf5cf3
Merge branch 'main' into parameter-manager-parameter-resource-support
abheda-crest 790ee5d
change api version to beta only
abheda-crest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Copyright 2024 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
name: 'Parameter' | ||
description: | | ||
A Parameter resource is a logical parameter. | ||
min_version: 'beta' | ||
references: | ||
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' | ||
self_link: 'projects/{{project}}/locations/global/parameters/{{parameter_id}}' | ||
create_url: 'projects/{{project}}/locations/global/parameters?parameter_id={{parameter_id}}' | ||
update_verb: 'PATCH' | ||
update_mask: true | ||
import_format: | ||
- 'projects/{{project}}/locations/global/parameters/{{parameter_id}}' | ||
timeouts: | ||
insert_minutes: 20 | ||
update_minutes: 20 | ||
delete_minutes: 20 | ||
examples: | ||
- name: 'parameter_config_basic' | ||
primary_resource_id: 'parameter-basic' | ||
min_version: 'beta' | ||
vars: | ||
parameter_id: 'parameter' | ||
- name: 'parameter_with_format' | ||
primary_resource_id: 'parameter-with-format' | ||
min_version: 'beta' | ||
vars: | ||
parameter_id: 'parameter' | ||
- name: 'parameter_with_labels' | ||
primary_resource_id: 'parameter-with-labels' | ||
min_version: 'beta' | ||
vars: | ||
parameter_id: 'parameter' | ||
parameters: | ||
- name: 'parameterId' | ||
type: String | ||
description: | | ||
This must be unique within the project. | ||
min_version: 'beta' | ||
url_param_only: true | ||
required: true | ||
immutable: true | ||
properties: | ||
- name: 'name' | ||
type: String | ||
description: | | ||
The resource name of the Parameter. Format: | ||
`projects/{{project}}/locations/global/parameters/{{parameter_id}}` | ||
min_version: 'beta' | ||
output: true | ||
- name: 'createTime' | ||
type: String | ||
description: | | ||
The time at which the Parameter was created. | ||
min_version: 'beta' | ||
output: true | ||
- name: 'updateTime' | ||
type: String | ||
description: | | ||
The time at which the Parameter was updated. | ||
min_version: 'beta' | ||
output: true | ||
- name: 'policyMember' | ||
type: NestedObject | ||
description: | | ||
Policy member strings of a Google Cloud resource. | ||
min_version: 'beta' | ||
output: true | ||
properties: | ||
- name: 'iamPolicyUidPrincipal' | ||
type: String | ||
description: | | ||
IAM policy binding member referring to a Google Cloud resource by system-assigned unique identifier. | ||
If a resource is deleted and recreated with the same name, the binding will not be applicable to the | ||
new resource. Format: | ||
`principal://parametermanager.googleapis.com/projects/{{project}}/uid/locations/global/parameters/{{uid}}` | ||
min_version: 'beta' | ||
output: true | ||
- name: 'iamPolicyNamePrincipal' | ||
type: String | ||
description: | | ||
IAM policy binding member referring to a Google Cloud resource by user-assigned name. If a | ||
resource is deleted and recreated with the same name, the binding will be applicable to the | ||
new resource. Format: | ||
`principal://parametermanager.googleapis.com/projects/{{project}}/name/locations/global/parameters/{{parameter_id}}` | ||
min_version: 'beta' | ||
output: true | ||
- name: 'labels' | ||
type: KeyValueLabels | ||
description: | | ||
The labels assigned to this Parameter. | ||
|
||
Label keys must be between 1 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, | ||
and must conform to the following PCRE regular expression: [\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62} | ||
|
||
Label values must be between 0 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, | ||
and must conform to the following PCRE regular expression: [\p{Ll}\p{Lo}\p{N}_-]{0,63} | ||
|
||
No more than 64 labels can be assigned to a given resource. | ||
|
||
An object containing a list of "key": value pairs. Example: | ||
{ "name": "wrench", "mass": "1.3kg", "count": "3" }. | ||
min_version: 'beta' | ||
- name: 'format' | ||
type: Enum | ||
description: | | ||
The format type of the parameter resource. Default value is UNFORMATTED. | ||
min_version: 'beta' | ||
default_from_api: true | ||
immutable: true | ||
enum_values: | ||
- 'UNFORMATTED' | ||
- 'YAML' | ||
- 'JSON' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2024 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
name: 'ParameterManager' | ||
display_name: 'Parameter Manager' | ||
versions: | ||
- name: 'beta' | ||
base_url: 'https://parametermanager.googleapis.com/v1/' | ||
scopes: | ||
- 'https://www.googleapis.com/auth/cloud-platform' |
4 changes: 4 additions & 0 deletions
4
mmv1/templates/terraform/examples/parameter_config_basic.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
} |
5 changes: 5 additions & 0 deletions
5
mmv1/templates/terraform/examples/parameter_with_format.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
format = "JSON" | ||
} |
12 changes: 12 additions & 0 deletions
12
mmv1/templates/terraform/examples/parameter_with_labels.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "val2" | ||
key3 = "val3" | ||
key4 = "val4" | ||
key5 = "val5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
...rty/terraform/services/parametermanager/resource_parameter_manager_parameter_test.go.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package parametermanager_test | ||
{{- if ne $.TargetVersionName "ga" }} | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
) | ||
|
||
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) | ||
} | ||
|
||
func TestAccParameterManagerParameter_labelsUpdate(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_withoutLabels(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_parameter.parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccParameterManagerParameter_labelsUpdate(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_parameter.parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccParameterManagerParameter_labelsUpdateOther(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_parameter.parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccParameterManagerParameter_withoutLabels(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_parameter.parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccParameterManagerParameter_withoutLabels(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_parameter" "parameter-with-labels" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
format = "JSON" | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccParameterManagerParameter_labelsUpdate(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_parameter" "parameter-with-labels" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
format = "JSON" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "val2" | ||
key3 = "val3" | ||
key4 = "val4" | ||
key5 = "val5" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccParameterManagerParameter_labelsUpdateOther(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_parameter" "parameter-with-labels" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
format = "JSON" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "updateval2" | ||
updatekey3 = "val3" | ||
updatekey4 = "updateval4" | ||
key6 = "val6" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
{{ end }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
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.