diff --git a/mmv1/products/parametermanager/Parameter.yaml b/mmv1/products/parametermanager/Parameter.yaml new file mode 100644 index 000000000000..0c7e54d884ad --- /dev/null +++ b/mmv1/products/parametermanager/Parameter.yaml @@ -0,0 +1,121 @@ +# 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. + 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}}` + output: true + - name: 'createTime' + type: String + description: | + The time at which the Parameter was created. + output: true + - name: 'updateTime' + type: String + description: | + The time at which the Parameter was updated. + output: true + - name: 'policyMember' + type: NestedObject + description: | + Policy member strings of a Google Cloud resource. + 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}}` + 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}}` + 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" }. + - name: 'format' + type: Enum + description: | + The format type of the parameter resource. Default value is UNFORMATTED. + default_from_api: true + immutable: true + enum_values: + - 'UNFORMATTED' + - 'YAML' + - 'JSON' diff --git a/mmv1/products/parametermanager/product.yaml b/mmv1/products/parametermanager/product.yaml new file mode 100644 index 000000000000..4a0184ba77c7 --- /dev/null +++ b/mmv1/products/parametermanager/product.yaml @@ -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' diff --git a/mmv1/templates/terraform/examples/parameter_config_basic.tf.tmpl b/mmv1/templates/terraform/examples/parameter_config_basic.tf.tmpl new file mode 100644 index 000000000000..b31380eee821 --- /dev/null +++ b/mmv1/templates/terraform/examples/parameter_config_basic.tf.tmpl @@ -0,0 +1,4 @@ +resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { + provider = google-beta + parameter_id = "{{index $.Vars "parameter_id"}}" +} diff --git a/mmv1/templates/terraform/examples/parameter_with_format.tf.tmpl b/mmv1/templates/terraform/examples/parameter_with_format.tf.tmpl new file mode 100644 index 000000000000..dd78230835a4 --- /dev/null +++ b/mmv1/templates/terraform/examples/parameter_with_format.tf.tmpl @@ -0,0 +1,5 @@ +resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { + provider = google-beta + parameter_id = "{{index $.Vars "parameter_id"}}" + format = "JSON" +} diff --git a/mmv1/templates/terraform/examples/parameter_with_labels.tf.tmpl b/mmv1/templates/terraform/examples/parameter_with_labels.tf.tmpl new file mode 100644 index 000000000000..8d990cd7a1a3 --- /dev/null +++ b/mmv1/templates/terraform/examples/parameter_with_labels.tf.tmpl @@ -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" + } +} diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt index 24abf96b5b4f..f641ac3c4873 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt @@ -591,6 +591,11 @@ var ServicesListBeta = mapOf( "displayName" to "Parallelstore", "path" to "./google/services/parallelstore" ), + "parametermanager" to mapOf( + "name" to "parametermanager", + "displayName" to "Parametermanager", + "path" to "./google-beta/services/parametermanager" + ), "privateca" to mapOf( "name" to "privateca", "displayName" to "Privateca", diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt index a5bb12bca8f1..6cbed908e22d 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt @@ -586,6 +586,11 @@ var ServicesListGa = mapOf( "displayName" to "Parallelstore", "path" to "./google/services/parallelstore" ), + "parametermanager" to mapOf( + "name" to "parametermanager", + "displayName" to "Parametermanager", + "path" to "./google/services/parametermanager" + ), "privateca" to mapOf( "name" to "privateca", "displayName" to "Privateca", diff --git a/mmv1/third_party/terraform/services/parametermanager/resource_parameter_manager_parameter_test.go.tmpl b/mmv1/third_party/terraform/services/parametermanager/resource_parameter_manager_parameter_test.go.tmpl new file mode 100644 index 000000000000..82bdac95e1a1 --- /dev/null +++ b/mmv1/third_party/terraform/services/parametermanager/resource_parameter_manager_parameter_test.go.tmpl @@ -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 }}