Skip to content

Commit

Permalink
Change region field required to default_from_api (#10724) (#7384)
Browse files Browse the repository at this point in the history
[upstream:2f6d3ced689d299474ec30ef7b38838a2e62c1d4]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored May 17, 2024
1 parent 76530e3 commit ce61546
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ first character must be a lowercase letter, and all following
characters must be a dash, lowercase letter, or digit, except the last
character, which cannot be a dash.`,
},
"region": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `The region where the regional SSL policy resides.`,
},
"custom_features": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -136,6 +129,14 @@ for information on what cipher suites each profile provides. If
'CUSTOM' is used, the 'custom_features' attribute **must be set**. Default value: "COMPATIBLE" Possible values: ["COMPATIBLE", "MODERN", "RESTRICTED", "CUSTOM"]`,
Default: "COMPATIBLE",
},
"region": {
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: `The region where the regional SSL policy resides.`,
},
"creation_timestamp": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -555,7 +556,7 @@ func flattenComputeRegionSslPolicyRegion(v interface{}, d *schema.ResourceData,
if v == nil {
return v
}
return tpgresource.ConvertSelfLinkToV1(v.(string))
return tpgresource.NameFromSelfLinkStateFunc(v)
}

func expandComputeRegionSslPolicyDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,36 @@ import (
compute "google.golang.org/api/compute/v0.beta"
)

func TestAccComputeRegionSslPolicy_regionInherit(t *testing.T) {
t.Parallel()

sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(t, 10))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeSslPolicyDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRegionSslRegionDefaultFromEnv(sslPolicyName),
},
{
ResourceName: "google_compute_region_ssl_policy.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeRegionSslUpdateRegionDefaultFromEnv(sslPolicyName),
},
{
ResourceName: "google_compute_region_ssl_policy.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccComputeRegionSslPolicy_update(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -226,3 +256,25 @@ resource "google_compute_region_ssl_policy" "update" {
}
`, resourceName)
}

func testAccComputeRegionSslRegionDefaultFromEnv(resourceName string) string {
return fmt.Sprintf(`
resource "google_compute_region_ssl_policy" "foobar" {
name = "%s"
description = "Generated by TF provider acceptance test"
min_tls_version = "TLS_1_0"
profile = "MODERN"
}
`, resourceName)
}

func testAccComputeRegionSslUpdateRegionDefaultFromEnv(resourceName string) string {
return fmt.Sprintf(`
resource "google_compute_region_ssl_policy" "foobar" {
name = "%s"
description = "Generated by TF provider acceptance test - updated"
min_tls_version = "TLS_1_0"
profile = "MODERN"
}
`, resourceName)
}
8 changes: 4 additions & 4 deletions website/docs/r/compute_region_ssl_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ The following arguments are supported:
characters must be a dash, lowercase letter, or digit, except the last
character, which cannot be a dash.

* `region` -
(Required)
The region where the regional SSL policy resides.


- - -

Expand Down Expand Up @@ -85,6 +81,10 @@ The following arguments are supported:
*must* be present when using the `CUSTOM` profile. This argument
*must not* be present when using any other profile.

* `region` -
(Optional)
The region where the regional SSL policy resides.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

Expand Down

0 comments on commit ce61546

Please sign in to comment.