-
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
ad8658e
e81bbc0
ccf5cf3
790ee5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# 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. | ||
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' | ||
vars: | ||
parameter_id: 'parameter' | ||
- name: 'parameter_with_format' | ||
primary_resource_id: 'parameter-with-format' | ||
vars: | ||
parameter_id: 'parameter' | ||
- name: 'parameter_with_labels' | ||
primary_resource_id: 'parameter-with-labels' | ||
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' |
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: 'ParameterManager' | ||
display_name: 'Parameter Manager' | ||
versions: | ||
- name: 'ga' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this API is in a Pre-GA state, so we shouldn't add it to the GA provider at this point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, let's add this to beta provide only for now. |
||
base_url: 'https://parametermanager.googleapis.com/v1/' | ||
- name: 'beta' | ||
base_url: 'https://parametermanager.googleapis.com/v1/' | ||
scopes: | ||
- 'https://www.googleapis.com/auth/cloud-platform' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
format = "JSON" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
resource "google_parameter_manager_parameter" "{{$.PrimaryResourceId}}" { | ||
parameter_id = "{{index $.Vars "parameter_id"}}" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "val2" | ||
key3 = "val3" | ||
key4 = "val4" | ||
key5 = "val5" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
package parametermanager_test | ||
|
||
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.ProtoV5ProviderFactories(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" { | ||
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.ProtoV5ProviderFactories(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" { | ||
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" { | ||
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" { | ||
parameter_id = "tf_test_parameter%{random_suffix}" | ||
format = "JSON" | ||
|
||
labels = { | ||
key1 = "val1" | ||
key2 = "updateval2" | ||
updatekey3 = "val3" | ||
updatekey4 = "updateval4" | ||
key6 = "val6" | ||
} | ||
} | ||
`, 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.
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.