diff --git a/.changelog/12630.txt b/.changelog/12630.txt new file mode 100644 index 0000000000..2d3807f90e --- /dev/null +++ b/.changelog/12630.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +`google_parameter_manager_parameter` +``` \ No newline at end of file diff --git a/google-beta/fwmodels/provider_model.go b/google-beta/fwmodels/provider_model.go index 315a8f1173..ab5b56113a 100644 --- a/google-beta/fwmodels/provider_model.go +++ b/google-beta/fwmodels/provider_model.go @@ -137,6 +137,7 @@ type ProviderModel struct { OSConfigCustomEndpoint types.String `tfsdk:"os_config_custom_endpoint"` OSLoginCustomEndpoint types.String `tfsdk:"os_login_custom_endpoint"` ParallelstoreCustomEndpoint types.String `tfsdk:"parallelstore_custom_endpoint"` + ParameterManagerCustomEndpoint types.String `tfsdk:"parameter_manager_custom_endpoint"` ParameterManagerRegionalCustomEndpoint types.String `tfsdk:"parameter_manager_regional_custom_endpoint"` PrivatecaCustomEndpoint types.String `tfsdk:"privateca_custom_endpoint"` PrivilegedAccessManagerCustomEndpoint types.String `tfsdk:"privileged_access_manager_custom_endpoint"` diff --git a/google-beta/fwprovider/framework_provider.go b/google-beta/fwprovider/framework_provider.go index 9998640d93..127e5b903c 100644 --- a/google-beta/fwprovider/framework_provider.go +++ b/google-beta/fwprovider/framework_provider.go @@ -803,6 +803,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, + "parameter_manager_custom_endpoint": &schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + transport_tpg.CustomEndpointValidator(), + }, + }, "parameter_manager_regional_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ diff --git a/google-beta/provider/provider.go b/google-beta/provider/provider.go index d01b55876b..007c8eb0dc 100644 --- a/google-beta/provider/provider.go +++ b/google-beta/provider/provider.go @@ -683,6 +683,11 @@ func Provider() *schema.Provider { Optional: true, ValidateFunc: transport_tpg.ValidateCustomEndpoint, }, + "parameter_manager_custom_endpoint": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: transport_tpg.ValidateCustomEndpoint, + }, "parameter_manager_regional_custom_endpoint": { Type: schema.TypeString, Optional: true, @@ -1172,6 +1177,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.OSConfigBasePath = d.Get("os_config_custom_endpoint").(string) config.OSLoginBasePath = d.Get("os_login_custom_endpoint").(string) config.ParallelstoreBasePath = d.Get("parallelstore_custom_endpoint").(string) + config.ParameterManagerBasePath = d.Get("parameter_manager_custom_endpoint").(string) config.ParameterManagerRegionalBasePath = d.Get("parameter_manager_regional_custom_endpoint").(string) config.PrivatecaBasePath = d.Get("privateca_custom_endpoint").(string) config.PrivilegedAccessManagerBasePath = d.Get("privileged_access_manager_custom_endpoint").(string) diff --git a/google-beta/provider/provider_mmv1_resources.go b/google-beta/provider/provider_mmv1_resources.go index ad4c587ce9..e8786637de 100644 --- a/google-beta/provider/provider_mmv1_resources.go +++ b/google-beta/provider/provider_mmv1_resources.go @@ -111,6 +111,7 @@ import ( "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/osconfig" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/oslogin" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/parallelstore" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/parametermanager" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/parametermanagerregional" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/privateca" "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/privilegedaccessmanager" @@ -515,9 +516,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{ } // Resources -// Generated resources: 582 +// Generated resources: 583 // Generated IAM resources: 294 -// Total generated resources: 876 +// Total generated resources: 877 var generatedResources = map[string]*schema.Resource{ "google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(), "google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(), @@ -1209,6 +1210,7 @@ var generatedResources = map[string]*schema.Resource{ "google_os_config_patch_deployment": osconfig.ResourceOSConfigPatchDeployment(), "google_os_login_ssh_public_key": oslogin.ResourceOSLoginSSHPublicKey(), "google_parallelstore_instance": parallelstore.ResourceParallelstoreInstance(), + "google_parameter_manager_parameter": parametermanager.ResourceParameterManagerParameter(), "google_parameter_manager_regional_parameter": parametermanagerregional.ResourceParameterManagerRegionalRegionalParameter(), "google_privateca_ca_pool": privateca.ResourcePrivatecaCaPool(), "google_privateca_ca_pool_iam_binding": tpgiamresource.ResourceIamBinding(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc), diff --git a/google-beta/services/parametermanager/resource_parameter_manager_parameter.go b/google-beta/services/parametermanager/resource_parameter_manager_parameter.go new file mode 100644 index 0000000000..02db70a0be --- /dev/null +++ b/google-beta/services/parametermanager/resource_parameter_manager_parameter.go @@ -0,0 +1,524 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package parametermanager + +import ( + "fmt" + "log" + "net/http" + "reflect" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify" +) + +func ResourceParameterManagerParameter() *schema.Resource { + return &schema.Resource{ + Create: resourceParameterManagerParameterCreate, + Read: resourceParameterManagerParameterRead, + Update: resourceParameterManagerParameterUpdate, + Delete: resourceParameterManagerParameterDelete, + + Importer: &schema.ResourceImporter{ + State: resourceParameterManagerParameterImport, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(20 * time.Minute), + Update: schema.DefaultTimeout(20 * time.Minute), + Delete: schema.DefaultTimeout(20 * time.Minute), + }, + + CustomizeDiff: customdiff.All( + tpgresource.SetLabelsDiff, + tpgresource.DefaultProviderProject, + ), + + Schema: map[string]*schema.Schema{ + "parameter_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `This must be unique within the project.`, + }, + "format": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"UNFORMATTED", "YAML", "JSON", ""}), + Description: `The format type of the parameter resource. Default value: "UNFORMATTED" Possible values: ["UNFORMATTED", "YAML", "JSON"]`, + Default: "UNFORMATTED", + }, + "labels": { + Type: schema.TypeMap, + Optional: true, + 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" }. + + +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "create_time": { + Type: schema.TypeString, + Computed: true, + Description: `The time at which the Parameter was created.`, + }, + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: `The resource name of the Parameter. Format: +'projects/{{project}}/locations/global/parameters/{{parameter_id}}'`, + }, + "policy_member": { + Type: schema.TypeList, + Computed: true, + Description: `Policy member strings of a Google Cloud resource.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "iam_policy_name_principal": { + Type: schema.TypeString, + Computed: true, + 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}}'`, + }, + "iam_policy_uid_principal": { + Type: schema.TypeString, + Computed: true, + 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}}'`, + }, + }, + }, + }, + "terraform_labels": { + Type: schema.TypeMap, + Computed: true, + Description: `The combination of labels configured directly on the resource + and default labels configured on the provider.`, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: `The time at which the Parameter was updated.`, + }, + "project": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + }, + UseJSONNumber: true, + } +} + +func resourceParameterManagerParameterCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + obj := make(map[string]interface{}) + formatProp, err := expandParameterManagerParameterFormat(d.Get("format"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("format"); !tpgresource.IsEmptyValue(reflect.ValueOf(formatProp)) && (ok || !reflect.DeepEqual(v, formatProp)) { + obj["format"] = formatProp + } + labelsProp, err := expandParameterManagerParameterEffectiveLabels(d.Get("effective_labels"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { + obj["labels"] = labelsProp + } + + url, err := tpgresource.ReplaceVars(d, config, "{{ParameterManagerBasePath}}projects/{{project}}/locations/global/parameters?parameter_id={{parameter_id}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Creating new Parameter: %#v", obj) + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for Parameter: %s", err) + } + billingProject = project + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + headers := make(http.Header) + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "POST", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutCreate), + Headers: headers, + }) + if err != nil { + return fmt.Errorf("Error creating Parameter: %s", err) + } + if err := d.Set("name", flattenParameterManagerParameterName(res["name"], d, config)); err != nil { + return fmt.Errorf(`Error setting computed identity field "name": %s`, err) + } + + // Store the ID now + id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/global/parameters/{{parameter_id}}") + if err != nil { + return fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + log.Printf("[DEBUG] Finished creating Parameter %q: %#v", d.Id(), res) + + return resourceParameterManagerParameterRead(d, meta) +} + +func resourceParameterManagerParameterRead(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + url, err := tpgresource.ReplaceVars(d, config, "{{ParameterManagerBasePath}}projects/{{project}}/locations/global/parameters/{{parameter_id}}") + if err != nil { + return err + } + + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for Parameter: %s", err) + } + billingProject = project + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + headers := make(http.Header) + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "GET", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Headers: headers, + }) + if err != nil { + return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ParameterManagerParameter %q", d.Id())) + } + + if err := d.Set("project", project); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + + if err := d.Set("name", flattenParameterManagerParameterName(res["name"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + if err := d.Set("create_time", flattenParameterManagerParameterCreateTime(res["createTime"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + if err := d.Set("update_time", flattenParameterManagerParameterUpdateTime(res["updateTime"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + if err := d.Set("policy_member", flattenParameterManagerParameterPolicyMember(res["policyMember"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + if err := d.Set("labels", flattenParameterManagerParameterLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + if err := d.Set("format", flattenParameterManagerParameterFormat(res["format"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + if err := d.Set("terraform_labels", flattenParameterManagerParameterTerraformLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + if err := d.Set("effective_labels", flattenParameterManagerParameterEffectiveLabels(res["labels"], d, config)); err != nil { + return fmt.Errorf("Error reading Parameter: %s", err) + } + + return nil +} + +func resourceParameterManagerParameterUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for Parameter: %s", err) + } + billingProject = project + + obj := make(map[string]interface{}) + labelsProp, err := expandParameterManagerParameterEffectiveLabels(d.Get("effective_labels"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { + obj["labels"] = labelsProp + } + + url, err := tpgresource.ReplaceVars(d, config, "{{ParameterManagerBasePath}}projects/{{project}}/locations/global/parameters/{{parameter_id}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Updating Parameter %q: %#v", d.Id(), obj) + headers := make(http.Header) + updateMask := []string{} + + if d.HasChange("effective_labels") { + updateMask = append(updateMask, "labels") + } + // updateMask is a URL parameter but not present in the schema, so ReplaceVars + // won't set it + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) + if err != nil { + return err + } + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + // if updateMask is empty we are not updating anything so skip the post + if len(updateMask) > 0 { + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "PATCH", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutUpdate), + Headers: headers, + }) + + if err != nil { + return fmt.Errorf("Error updating Parameter %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating Parameter %q: %#v", d.Id(), res) + } + + } + + return resourceParameterManagerParameterRead(d, meta) +} + +func resourceParameterManagerParameterDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + project, err := tpgresource.GetProject(d, config) + if err != nil { + return fmt.Errorf("Error fetching project for Parameter: %s", err) + } + billingProject = project + + url, err := tpgresource.ReplaceVars(d, config, "{{ParameterManagerBasePath}}projects/{{project}}/locations/global/parameters/{{parameter_id}}") + if err != nil { + return err + } + + var obj map[string]interface{} + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + headers := make(http.Header) + + log.Printf("[DEBUG] Deleting Parameter %q", d.Id()) + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "DELETE", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutDelete), + Headers: headers, + }) + if err != nil { + return transport_tpg.HandleNotFoundError(err, d, "Parameter") + } + + log.Printf("[DEBUG] Finished deleting Parameter %q: %#v", d.Id(), res) + return nil +} + +func resourceParameterManagerParameterImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*transport_tpg.Config) + if err := tpgresource.ParseImportId([]string{ + "^projects/(?P[^/]+)/locations/global/parameters/(?P[^/]+)$", + "^(?P[^/]+)/(?P[^/]+)$", + "^(?P[^/]+)$", + }, d, config); err != nil { + return nil, err + } + + // Replace import id for the resource id + id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/global/parameters/{{parameter_id}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) + } + d.SetId(id) + + return []*schema.ResourceData{d}, nil +} + +func flattenParameterManagerParameterName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenParameterManagerParameterCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenParameterManagerParameterUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenParameterManagerParameterPolicyMember(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["iam_policy_uid_principal"] = + flattenParameterManagerParameterPolicyMemberIamPolicyUidPrincipal(original["iamPolicyUidPrincipal"], d, config) + transformed["iam_policy_name_principal"] = + flattenParameterManagerParameterPolicyMemberIamPolicyNamePrincipal(original["iamPolicyNamePrincipal"], d, config) + return []interface{}{transformed} +} +func flattenParameterManagerParameterPolicyMemberIamPolicyUidPrincipal(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenParameterManagerParameterPolicyMemberIamPolicyNamePrincipal(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenParameterManagerParameterLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return v + } + + transformed := make(map[string]interface{}) + if l, ok := d.GetOkExists("labels"); ok { + for k := range l.(map[string]interface{}) { + transformed[k] = v.(map[string]interface{})[k] + } + } + + return transformed +} + +func flattenParameterManagerParameterFormat(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenParameterManagerParameterTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return v + } + + transformed := make(map[string]interface{}) + if l, ok := d.GetOkExists("terraform_labels"); ok { + for k := range l.(map[string]interface{}) { + transformed[k] = v.(map[string]interface{})[k] + } + } + + return transformed +} + +func flattenParameterManagerParameterEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func expandParameterManagerParameterFormat(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandParameterManagerParameterEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { + if v == nil { + return map[string]string{}, nil + } + m := make(map[string]string) + for k, val := range v.(map[string]interface{}) { + m[k] = val.(string) + } + return m, nil +} diff --git a/google-beta/services/parametermanager/resource_parameter_manager_parameter_generated_meta.yaml b/google-beta/services/parametermanager/resource_parameter_manager_parameter_generated_meta.yaml new file mode 100644 index 0000000000..a2d56aa54e --- /dev/null +++ b/google-beta/services/parametermanager/resource_parameter_manager_parameter_generated_meta.yaml @@ -0,0 +1,5 @@ +resource: 'google_parameter_manager_parameter' +generation_type: 'mmv1' +api_service_name: 'parametermanager.googleapis.com' +api_version: 'v1' +api_resource_type_kind: 'Parameter' diff --git a/google-beta/services/parametermanager/resource_parameter_manager_parameter_generated_test.go b/google-beta/services/parametermanager/resource_parameter_manager_parameter_generated_test.go new file mode 100644 index 0000000000..35641d89f8 --- /dev/null +++ b/google-beta/services/parametermanager/resource_parameter_manager_parameter_generated_test.go @@ -0,0 +1,181 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package parametermanager_test + +import ( + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + + "github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +func TestAccParameterManagerParameter_parameterConfigBasicExample(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_parameterConfigBasicExample(context), + }, + { + ResourceName: "google_parameter_manager_parameter.parameter-basic", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, + }, + }, + }) +} + +func testAccParameterManagerParameter_parameterConfigBasicExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_parameter_manager_parameter" "parameter-basic" { + provider = google-beta + parameter_id = "parameter%{random_suffix}" +} +`, context) +} + +func TestAccParameterManagerParameter_parameterWithFormatExample(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_parameterWithFormatExample(context), + }, + { + ResourceName: "google_parameter_manager_parameter.parameter-with-format", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, + }, + }, + }) +} + +func testAccParameterManagerParameter_parameterWithFormatExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_parameter_manager_parameter" "parameter-with-format" { + provider = google-beta + parameter_id = "parameter%{random_suffix}" + format = "JSON" +} +`, context) +} + +func TestAccParameterManagerParameter_parameterWithLabelsExample(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_parameterWithLabelsExample(context), + }, + { + ResourceName: "google_parameter_manager_parameter.parameter-with-labels", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "parameter_id", "terraform_labels"}, + }, + }, + }) +} + +func testAccParameterManagerParameter_parameterWithLabelsExample(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_parameter_manager_parameter" "parameter-with-labels" { + provider = google-beta + parameter_id = "parameter%{random_suffix}" + + labels = { + key1 = "val1" + key2 = "val2" + key3 = "val3" + key4 = "val4" + key5 = "val5" + } +} +`, context) +} + +func testAccCheckParameterManagerParameterDestroyProducer(t *testing.T) func(s *terraform.State) error { + return func(s *terraform.State) error { + for name, rs := range s.RootModule().Resources { + if rs.Type != "google_parameter_manager_parameter" { + continue + } + if strings.HasPrefix(name, "data.") { + continue + } + + config := acctest.GoogleProviderConfig(t) + + url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{ParameterManagerBasePath}}projects/{{project}}/locations/global/parameters/{{parameter_id}}") + if err != nil { + return err + } + + billingProject := "" + + if config.BillingProject != "" { + billingProject = config.BillingProject + } + + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "GET", + Project: billingProject, + RawURL: url, + UserAgent: config.UserAgent, + }) + if err == nil { + return fmt.Errorf("ParameterManagerParameter still exists at %s", url) + } + } + + return nil + } +} diff --git a/google-beta/services/parametermanager/resource_parameter_manager_parameter_sweeper.go b/google-beta/services/parametermanager/resource_parameter_manager_parameter_sweeper.go new file mode 100644 index 0000000000..c2692fadbf --- /dev/null +++ b/google-beta/services/parametermanager/resource_parameter_manager_parameter_sweeper.go @@ -0,0 +1,143 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + +package parametermanager + +import ( + "context" + "log" + "strings" + "testing" + + "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/sweeper" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +func init() { + sweeper.AddTestSweepers("ParameterManagerParameter", testSweepParameterManagerParameter) +} + +// At the time of writing, the CI only passes us-central1 as the region +func testSweepParameterManagerParameter(region string) error { + resourceName := "ParameterManagerParameter" + log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) + + config, err := sweeper.SharedConfigForRegion(region) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) + return err + } + + err = config.LoadAndValidate(context.Background()) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) + return err + } + + t := &testing.T{} + billingId := envvar.GetTestBillingAccountFromEnv(t) + + // Setup variables to replace in list template + d := &tpgresource.ResourceDataMock{ + FieldsInSchema: map[string]interface{}{ + "project": config.Project, + "region": region, + "location": region, + "zone": "-", + "billing_account": billingId, + }, + } + + listTemplate := strings.Split("https://parametermanager.googleapis.com/v1/projects/{{project}}/locations/global/parameters", "?")[0] + listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) + return nil + } + + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "GET", + Project: config.Project, + RawURL: listUrl, + UserAgent: config.UserAgent, + }) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) + return nil + } + + resourceList, ok := res["parameters"] + if !ok { + log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") + return nil + } + + rl := resourceList.([]interface{}) + + log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) + // Keep count of items that aren't sweepable for logging. + nonPrefixCount := 0 + for _, ri := range rl { + obj := ri.(map[string]interface{}) + var name string + // Id detected in the delete URL, attempt to use id. + if obj["id"] != nil { + name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) + } else if obj["name"] != nil { + name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) + } else { + log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) + return nil + } + // Skip resources that shouldn't be sweeped + if !sweeper.IsSweepableTestResource(name) { + nonPrefixCount++ + continue + } + + deleteTemplate := "https://parametermanager.googleapis.com/v1/projects/{{project}}/locations/global/parameters/{{parameter_id}}" + deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) + return nil + } + deleteUrl = deleteUrl + name + + // Don't wait on operations as we may have a lot to delete + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "DELETE", + Project: config.Project, + RawURL: deleteUrl, + UserAgent: config.UserAgent, + }) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) + } else { + log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) + } + } + + if nonPrefixCount > 0 { + log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) + } + + return nil +} diff --git a/google-beta/services/parametermanager/resource_parameter_manager_parameter_test.go b/google-beta/services/parametermanager/resource_parameter_manager_parameter_test.go new file mode 100644 index 0000000000..d7cda9c608 --- /dev/null +++ b/google-beta/services/parametermanager/resource_parameter_manager_parameter_test.go @@ -0,0 +1,108 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 +package parametermanager_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" +) + +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) +} diff --git a/google-beta/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go b/google-beta/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go index e10fae9335..56f88f1f9c 100644 --- a/google-beta/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go +++ b/google-beta/services/parametermanagerregional/resource_parameter_manager_regional_parameter.go @@ -70,11 +70,11 @@ func ResourceParameterManagerRegionalRegionalParameter() *schema.Resource { }, "format": { Type: schema.TypeString, - Computed: true, Optional: true, ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"UNFORMATTED", "YAML", "JSON", ""}), - Description: `The format type of the regional parameter. Default value is UNFORMATTED. Possible values: ["UNFORMATTED", "YAML", "JSON"]`, + Description: `The format type of the regional parameter. Default value: "UNFORMATTED" Possible values: ["UNFORMATTED", "YAML", "JSON"]`, + Default: "UNFORMATTED", }, "labels": { Type: schema.TypeMap, diff --git a/google-beta/sweeper/gcp_sweeper_test.go b/google-beta/sweeper/gcp_sweeper_test.go index 50ac693054..9be2a16c63 100644 --- a/google-beta/sweeper/gcp_sweeper_test.go +++ b/google-beta/sweeper/gcp_sweeper_test.go @@ -113,6 +113,7 @@ import ( _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/osconfig" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/oslogin" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/parallelstore" + _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/parametermanager" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/parametermanagerregional" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/privateca" _ "github.com/hashicorp/terraform-provider-google-beta/google-beta/services/privilegedaccessmanager" diff --git a/google-beta/transport/config.go b/google-beta/transport/config.go index 6de5f6b954..e0537b8ccc 100644 --- a/google-beta/transport/config.go +++ b/google-beta/transport/config.go @@ -297,6 +297,7 @@ type Config struct { OSConfigBasePath string OSLoginBasePath string ParallelstoreBasePath string + ParameterManagerBasePath string ParameterManagerRegionalBasePath string PrivatecaBasePath string PrivilegedAccessManagerBasePath string @@ -461,6 +462,7 @@ const OrgPolicyBasePathKey = "OrgPolicy" const OSConfigBasePathKey = "OSConfig" const OSLoginBasePathKey = "OSLogin" const ParallelstoreBasePathKey = "Parallelstore" +const ParameterManagerBasePathKey = "ParameterManager" const ParameterManagerRegionalBasePathKey = "ParameterManagerRegional" const PrivatecaBasePathKey = "Privateca" const PrivilegedAccessManagerBasePathKey = "PrivilegedAccessManager" @@ -619,6 +621,7 @@ var DefaultBasePaths = map[string]string{ OSConfigBasePathKey: "https://osconfig.googleapis.com/v1beta/", OSLoginBasePathKey: "https://oslogin.googleapis.com/v1/", ParallelstoreBasePathKey: "https://parallelstore.googleapis.com/v1beta/", + ParameterManagerBasePathKey: "https://parametermanager.googleapis.com/v1/", ParameterManagerRegionalBasePathKey: "https://parametermanager.{{location}}.rep.googleapis.com/v1/", PrivatecaBasePathKey: "https://privateca.googleapis.com/v1/", PrivilegedAccessManagerBasePathKey: "https://privilegedaccessmanager.googleapis.com/v1beta/", @@ -1276,6 +1279,11 @@ func SetEndpointDefaults(d *schema.ResourceData) error { "GOOGLE_PARALLELSTORE_CUSTOM_ENDPOINT", }, DefaultBasePaths[ParallelstoreBasePathKey])) } + if d.Get("parameter_manager_custom_endpoint") == "" { + d.Set("parameter_manager_custom_endpoint", MultiEnvDefault([]string{ + "GOOGLE_PARAMETER_MANAGER_CUSTOM_ENDPOINT", + }, DefaultBasePaths[ParameterManagerBasePathKey])) + } if d.Get("parameter_manager_regional_custom_endpoint") == "" { d.Set("parameter_manager_regional_custom_endpoint", MultiEnvDefault([]string{ "GOOGLE_PARAMETER_MANAGER_REGIONAL_CUSTOM_ENDPOINT", @@ -2527,6 +2535,7 @@ func ConfigureBasePaths(c *Config) { c.OSConfigBasePath = DefaultBasePaths[OSConfigBasePathKey] c.OSLoginBasePath = DefaultBasePaths[OSLoginBasePathKey] c.ParallelstoreBasePath = DefaultBasePaths[ParallelstoreBasePathKey] + c.ParameterManagerBasePath = DefaultBasePaths[ParameterManagerBasePathKey] c.ParameterManagerRegionalBasePath = DefaultBasePaths[ParameterManagerRegionalBasePathKey] c.PrivatecaBasePath = DefaultBasePaths[PrivatecaBasePathKey] c.PrivilegedAccessManagerBasePath = DefaultBasePaths[PrivilegedAccessManagerBasePathKey] diff --git a/website/docs/r/parameter_manager_parameter.html.markdown b/website/docs/r/parameter_manager_parameter.html.markdown new file mode 100644 index 0000000000..96cdc0648e --- /dev/null +++ b/website/docs/r/parameter_manager_parameter.html.markdown @@ -0,0 +1,202 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in +# .github/CONTRIBUTING.md. +# +# ---------------------------------------------------------------------------- +subcategory: "Parameter Manager" +description: |- + A Parameter resource is a logical parameter. +--- + +# google_parameter_manager_parameter + +A Parameter resource is a logical parameter. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + +To get more information about Parameter, see: + +* [API documentation](https://cloud.google.com/secret-manager/parameter-manager/docs/reference/rest/v1/projects.locations.parameters) + + +## Example Usage - Parameter Config Basic + + +```hcl +resource "google_parameter_manager_parameter" "parameter-basic" { + provider = google-beta + parameter_id = "parameter" +} +``` + +## Example Usage - Parameter With Format + + +```hcl +resource "google_parameter_manager_parameter" "parameter-with-format" { + provider = google-beta + parameter_id = "parameter" + format = "JSON" +} +``` + +## Example Usage - Parameter With Labels + + +```hcl +resource "google_parameter_manager_parameter" "parameter-with-labels" { + provider = google-beta + parameter_id = "parameter" + + labels = { + key1 = "val1" + key2 = "val2" + key3 = "val3" + key4 = "val4" + key5 = "val5" + } +} +``` + +## Argument Reference + +The following arguments are supported: + + +* `parameter_id` - + (Required) + This must be unique within the project. + + +- - - + + +* `labels` - + (Optional) + 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" }. + + **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. + Please refer to the field `effective_labels` for all of the labels present on the resource. + +* `format` - + (Optional) + The format type of the parameter resource. + Default value is `UNFORMATTED`. + Possible values are: `UNFORMATTED`, `YAML`, `JSON`. + +* `project` - (Optional) The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are exported: + +* `id` - an identifier for the resource with format `projects/{{project}}/locations/global/parameters/{{parameter_id}}` + +* `name` - + The resource name of the Parameter. Format: + `projects/{{project}}/locations/global/parameters/{{parameter_id}}` + +* `create_time` - + The time at which the Parameter was created. + +* `update_time` - + The time at which the Parameter was updated. + +* `policy_member` - + Policy member strings of a Google Cloud resource. + Structure is [documented below](#nested_policy_member). + +* `terraform_labels` - + The combination of labels configured directly on the resource + and default labels configured on the provider. + +* `effective_labels` - + All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. + + +The `policy_member` block contains: + +* `iam_policy_uid_principal` - + (Output) + 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}}` + +* `iam_policy_name_principal` - + (Output) + 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}}` + +## Timeouts + +This resource provides the following +[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: + +- `create` - Default is 20 minutes. +- `update` - Default is 20 minutes. +- `delete` - Default is 20 minutes. + +## Import + + +Parameter can be imported using any of these accepted formats: + +* `projects/{{project}}/locations/global/parameters/{{parameter_id}}` +* `{{project}}/{{parameter_id}}` +* `{{parameter_id}}` + + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Parameter using one of the formats above. For example: + +```tf +import { + id = "projects/{{project}}/locations/global/parameters/{{parameter_id}}" + to = google_parameter_manager_parameter.default +} +``` + +When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Parameter can be imported using one of the formats above. For example: + +``` +$ terraform import google_parameter_manager_parameter.default projects/{{project}}/locations/global/parameters/{{parameter_id}} +$ terraform import google_parameter_manager_parameter.default {{project}}/{{parameter_id}} +$ terraform import google_parameter_manager_parameter.default {{parameter_id}} +``` + +## User Project Overrides + +This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). diff --git a/website/docs/r/parameter_manager_regional_parameter.html.markdown b/website/docs/r/parameter_manager_regional_parameter.html.markdown index 335d1fd42f..6a9d57951e 100644 --- a/website/docs/r/parameter_manager_regional_parameter.html.markdown +++ b/website/docs/r/parameter_manager_regional_parameter.html.markdown @@ -116,7 +116,8 @@ The following arguments are supported: * `format` - (Optional) - The format type of the regional parameter. Default value is UNFORMATTED. + The format type of the regional parameter. + Default value is `UNFORMATTED`. Possible values are: `UNFORMATTED`, `YAML`, `JSON`. * `project` - (Optional) The ID of the project in which the resource belongs.