-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for parameter manager regional parameter resource `google…
…_parameter_manager_regional_parameter` (#12631)
- Loading branch information
1 parent
e49e760
commit 555fb5c
Showing
8 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
mmv1/products/parametermanagerregional/RegionalParameter.yaml
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,128 @@ | ||
# 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: 'RegionalParameter' | ||
api_resource_type_kind: Parameter | ||
description: | | ||
A Regional Parameter is a logical regional 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/{{location}}/parameters' | ||
self_link: 'projects/{{project}}/locations/{{location}}/parameters/{{parameter_id}}' | ||
create_url: 'projects/{{project}}/locations/{{location}}/parameters?parameter_id={{parameter_id}}' | ||
update_verb: 'PATCH' | ||
update_mask: true | ||
import_format: | ||
- 'projects/{{project}}/locations/{{location}}/parameters/{{parameter_id}}' | ||
timeouts: | ||
insert_minutes: 20 | ||
update_minutes: 20 | ||
delete_minutes: 20 | ||
examples: | ||
- name: 'regional_parameter_basic' | ||
primary_resource_id: 'regional-parameter-basic' | ||
min_version: 'beta' | ||
vars: | ||
parameter_id: 'regional_parameter' | ||
- name: 'regional_parameter_with_format' | ||
primary_resource_id: 'regional-parameter-with-format' | ||
min_version: 'beta' | ||
vars: | ||
parameter_id: 'regional_parameter' | ||
- name: 'regional_parameter_with_labels' | ||
primary_resource_id: 'regional-parameter-with-labels' | ||
min_version: 'beta' | ||
vars: | ||
parameter_id: 'regional_parameter' | ||
parameters: | ||
- name: 'location' | ||
type: String | ||
description: | | ||
The location of the regional parameter. eg us-central1 | ||
url_param_only: true | ||
required: true | ||
immutable: true | ||
- name: 'parameterId' | ||
type: String | ||
description: | | ||
This must be unique within the project. | ||
url_param_only: true | ||
required: true | ||
immutable: true | ||
properties: | ||
- name: 'name' | ||
type: String | ||
description: | | ||
The resource name of the regional Parameter. Format: | ||
`projects/{{project}}/locations/{{location}}/parameters/{{parameter_id}}` | ||
output: true | ||
- name: 'createTime' | ||
type: String | ||
description: | | ||
The time at which the regional Parameter was created. | ||
output: true | ||
- name: 'updateTime' | ||
type: String | ||
description: | | ||
The time at which the regional Parameter was updated. | ||
output: true | ||
- name: 'policyMember' | ||
type: NestedObject | ||
description: | | ||
An object containing a unique resource identity tied to the regional parameter. | ||
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/{{location}}/parameters/{{uid}}` | ||
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/{{location}}/parameters/{{parameter_id}}` | ||
output: true | ||
- name: 'labels' | ||
type: KeyValueLabels | ||
description: | | ||
The labels assigned to this regional 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" }. | ||
- name: 'format' | ||
type: Enum | ||
description: | | ||
The format type of the regional parameter. Default value is UNFORMATTED. | ||
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,23 @@ | ||
# 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: 'ParameterManagerRegional' | ||
legacy_name: 'parameter_manager' | ||
display_name: 'Parameter Manager' | ||
versions: | ||
- name: 'beta' | ||
base_url: 'https://parametermanager.{{location}}.rep.googleapis.com/v1/' | ||
cai_base_url: 'https://parametermanager.googleapis.com/v1/' | ||
scopes: | ||
- 'https://www.googleapis.com/auth/cloud-platform' |
5 changes: 5 additions & 0 deletions
5
mmv1/templates/terraform/examples/regional_parameter_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,5 @@ | ||
resource "google_parameter_manager_regional_parameter" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
location = "us-central1" | ||
} |
6 changes: 6 additions & 0 deletions
6
mmv1/templates/terraform/examples/regional_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,6 @@ | ||
resource "google_parameter_manager_regional_parameter" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
location = "us-central1" | ||
format = "JSON" | ||
} |
13 changes: 13 additions & 0 deletions
13
mmv1/templates/terraform/examples/regional_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,13 @@ | ||
resource "google_parameter_manager_regional_parameter" "{{$.PrimaryResourceId}}" { | ||
provider = google-beta | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
location = "us-central1" | ||
|
||
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
156 changes: 156 additions & 0 deletions
156
...vices/parametermanagerregional/resource_parameter_manager_regional_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,156 @@ | ||
package parametermanagerregional_test | ||
{{- if ne $.TargetVersionName "ga" }} | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
) | ||
|
||
func TestAccParameterManagerRegionalRegionalParameter_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: testAccCheckParameterManagerRegionalRegionalParameterDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccParameterManagerRegionalRegionalParameter_import(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_regional_parameter.regional-parameter-import", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "location", "parameter_id", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccParameterManagerRegionalRegionalParameter_import(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_regional_parameter" "regional-parameter-import" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
location = "us-central1" | ||
format = "YAML" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "val2" | ||
key3 = "val3" | ||
key4 = "val4" | ||
key5 = "val5" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func TestAccParameterManagerRegionalRegionalParameter_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: testAccCheckParameterManagerRegionalRegionalParameterDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccParameterManagerRegionalRegionalParameter_withoutLabels(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_regional_parameter.regional-parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "location", "parameter_id", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccParameterManagerRegionalRegionalParameter_labelsUpdate(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_regional_parameter.regional-parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "location", "parameter_id", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccParameterManagerRegionalRegionalParameter_labelsUpdateOther(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_regional_parameter.regional-parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "location", "parameter_id", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccParameterManagerRegionalRegionalParameter_withoutLabels(context), | ||
}, | ||
{ | ||
ResourceName: "google_parameter_manager_regional_parameter.regional-parameter-with-labels", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"labels", "location", "parameter_id", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccParameterManagerRegionalRegionalParameter_withoutLabels(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_regional_parameter" "regional-parameter-with-labels" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
location = "us-central1" | ||
format = "JSON" | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccParameterManagerRegionalRegionalParameter_labelsUpdate(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_regional_parameter" "regional-parameter-with-labels" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
location = "us-central1" | ||
format = "JSON" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "val2" | ||
key3 = "val3" | ||
key4 = "val4" | ||
key5 = "val5" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccParameterManagerRegionalRegionalParameter_labelsUpdateOther(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_parameter_manager_regional_parameter" "regional-parameter-with-labels" { | ||
provider = google-beta | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
location = "us-central1" | ||
format = "JSON" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "updateval2" | ||
updatekey3 = "val3" | ||
updatekey4 = "updateval4" | ||
key6 = "val6" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
{{ end }} |