Skip to content

Commit c822797

Browse files
authored
Revert "feat: support new field server_certificate_rotation_mode for SQL inst…" (GoogleCloudPlatform#16398)
1 parent c2acc21 commit c822797

File tree

4 files changed

+3
-80
lines changed

4 files changed

+3
-80
lines changed

mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ var (
8888
"settings.0.ip_configuration.0.ssl_mode",
8989
"settings.0.ip_configuration.0.server_ca_mode",
9090
"settings.0.ip_configuration.0.server_ca_pool",
91-
"settings.0.ip_configuration.0.server_certificate_rotation_mode",
9291
"settings.0.ip_configuration.0.custom_subject_alternative_names",
9392
}
9493

@@ -697,14 +696,6 @@ API (for read pools, effective_availability_type may differ from availability_ty
697696
Description: `The resource name of the server CA pool for an instance with "CUSTOMER_MANAGED_CAS_CA" as the "server_ca_mode".`,
698697
AtLeastOneOf: ipConfigurationKeys,
699698
},
700-
"server_certificate_rotation_mode": {
701-
Type: schema.TypeString,
702-
Optional: true,
703-
ValidateFunc: validation.StringInSlice([]string{"NO_AUTOMATIC_ROTATION", "AUTOMATIC_ROTATION_DURING_MAINTENANCE"}, false),
704-
Description: `Settings for how the server certificate gets rotated.`,
705-
AtLeastOneOf: ipConfigurationKeys,
706-
DiffSuppressFunc: serverCertificateRotationModeDiffSuppress,
707-
},
708699
"custom_subject_alternative_names": {
709700
Type: schema.TypeSet,
710701
Optional: true,
@@ -1885,7 +1876,6 @@ func expandIpConfiguration(configured []interface{}, databaseVersion string) *sq
18851876
SslMode: _ipConfiguration["ssl_mode"].(string),
18861877
ServerCaMode: _ipConfiguration["server_ca_mode"].(string),
18871878
ServerCaPool: _ipConfiguration["server_ca_pool"].(string),
1888-
ServerCertificateRotationMode: _ipConfiguration["server_certificate_rotation_mode"].(string),
18891879
CustomSubjectAlternativeNames: tpgresource.ConvertStringArr(_ipConfiguration["custom_subject_alternative_names"].(*schema.Set).List()),
18901880
}
18911881
}
@@ -2728,15 +2718,6 @@ func databaseVersionDiffSuppress(_, oldVersion, newVersion string, _ *schema.Res
27282718
return false
27292719
}
27302720

2731-
func serverCertificateRotationModeDiffSuppress(_, oldMode, newMode string, _ *schema.ResourceData) bool {
2732-
// If the value is not set in the configuration (new is empty)
2733-
// and the API returns the default UNSPECIFIED value, suppress the diff.
2734-
if newMode == "" && oldMode == "SERVER_CERTIFICATE_ROTATION_MODE_UNSPECIFIED" {
2735-
return true
2736-
}
2737-
return false
2738-
}
2739-
27402721
func resourceSqlDatabaseInstanceDelete(d *schema.ResourceData, meta interface{}) error {
27412722
config := meta.(*transport_tpg.Config)
27422723
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
@@ -3115,7 +3096,6 @@ func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration, d *schema
31153096
"ssl_mode": ipConfiguration.SslMode,
31163097
"server_ca_mode": ipConfiguration.ServerCaMode,
31173098
"server_ca_pool": ipConfiguration.ServerCaPool,
3118-
"server_certificate_rotation_mode": ipConfiguration.ServerCertificateRotationMode,
31193099
"custom_subject_alternative_names": ipConfiguration.CustomSubjectAlternativeNames,
31203100
}
31213101

mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml.tmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ fields:
163163
- api_field: 'settings.ipConfiguration.pscConfig.pscEnabled'
164164
- api_field: 'settings.ipConfiguration.serverCaMode'
165165
- api_field: 'settings.ipConfiguration.serverCaPool'
166-
- api_field: 'settings.ipConfiguration.serverCertificateRotationMode'
167166
- api_field: 'settings.ipConfiguration.sslMode'
168167
- api_field: 'settings.locationPreference.followGaeApplication'
169168
- api_field: 'settings.locationPreference.secondaryZone'

mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3908,7 +3908,6 @@ func TestAccSqlDatabaseInstance_useInternalCaByDefault(t *testing.T) {
39083908
Check: resource.ComposeTestCheckFunc(
39093909
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_INTERNAL_CA"),
39103910
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_pool", ""),
3911-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_certificate_rotation_mode", "SERVER_CERTIFICATE_ROTATION_MODE_UNSPECIFIED"),
39123911
),
39133912
},
39143913
{
@@ -3938,7 +3937,6 @@ func TestAccSqlDatabaseInstance_useCasBasedServerCa(t *testing.T) {
39383937
Check: resource.ComposeTestCheckFunc(
39393938
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_CAS_CA"),
39403939
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_pool", ""),
3941-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_certificate_rotation_mode", "SERVER_CERTIFICATE_ROTATION_MODE_UNSPECIFIED"),
39423940
resource.TestCheckResourceAttr(resourceName, "dns_names.#", "1"),
39433941
resource.TestCheckResourceAttr(resourceName, "dns_names.0.connection_type", "PUBLIC"),
39443942
resource.TestCheckResourceAttr(resourceName, "dns_names.0.dns_scope", "INSTANCE"),
@@ -3954,37 +3952,6 @@ func TestAccSqlDatabaseInstance_useCasBasedServerCa(t *testing.T) {
39543952
})
39553953
}
39563954

3957-
func TestAccSqlDatabaseInstance_setServerCertRotationMode(t *testing.T) {
3958-
t.Parallel()
3959-
3960-
databaseName := "tf-test-" + acctest.RandString(t, 10)
3961-
resourceName := "google_sql_database_instance.instance"
3962-
rotationMode := "AUTOMATIC_ROTATION_DURING_MAINTENANCE"
3963-
3964-
acctest.VcrTest(t, resource.TestCase{
3965-
PreCheck: func() { acctest.AccTestPreCheck(t) },
3966-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
3967-
CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t),
3968-
3969-
Steps: []resource.TestStep{
3970-
{
3971-
Config: testGoogleSqlDatabaseInstance_setServerCertRotationMode(databaseName, rotationMode),
3972-
Check: resource.ComposeTestCheckFunc(
3973-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_certificate_rotation_mode", rotationMode),
3974-
resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_CAS_CA"),
3975-
),
3976-
},
3977-
{
3978-
ResourceName: resourceName,
3979-
ImportState: true,
3980-
ImportStateVerify: true,
3981-
ImportStateVerifyIgnore: []string{"deletion_protection"},
3982-
},
3983-
},
3984-
})
3985-
}
3986-
3987-
39883955
func TestAccSqlDatabaseInstance_useCustomSubjectAlternateName(t *testing.T) {
39893956
t.Parallel()
39903957

@@ -4702,7 +4669,6 @@ resource "google_sql_database_instance" "instance" {
47024669
ipv4_enabled = "true"
47034670
server_ca_mode = "CUSTOMER_MANAGED_CAS_CA"
47044671
server_ca_pool = google_privateca_ca_pool.customer_ca_pool.id
4705-
server_certificate_rotation_mode = "AUTOMATIC_ROTATION_DURING_MAINTENANCE"
47064672
custom_subject_alternative_names = ["%{customSan}"]
47074673
}
47084674
}
@@ -4791,10 +4757,9 @@ resource "google_sql_database_instance" "instance" {
47914757
settings {
47924758
tier = "db-f1-micro"
47934759
ip_configuration {
4794-
ipv4_enabled = "true"
4795-
server_ca_mode = "CUSTOMER_MANAGED_CAS_CA"
4796-
server_ca_pool = google_privateca_ca_pool.customer_ca_pool.id
4797-
server_certificate_rotation_mode = "AUTOMATIC_ROTATION_DURING_MAINTENANCE"
4760+
ipv4_enabled = "true"
4761+
server_ca_mode = "CUSTOMER_MANAGED_CAS_CA"
4762+
server_ca_pool = google_privateca_ca_pool.customer_ca_pool.id
47984763
}
47994764
}
48004765
@@ -4821,25 +4786,6 @@ resource "google_sql_database_instance" "instance" {
48214786
`, databaseName, serverCaMode)
48224787
}
48234788

4824-
func testGoogleSqlDatabaseInstance_setServerCertRotationMode(databaseName, rotationMode string) string {
4825-
return fmt.Sprintf(`
4826-
resource "google_sql_database_instance" "instance" {
4827-
name = "%s"
4828-
region = "us-central1"
4829-
database_version = "POSTGRES_15"
4830-
deletion_protection = false
4831-
settings {
4832-
tier = "db-f1-micro"
4833-
ip_configuration {
4834-
ipv4_enabled = "true"
4835-
server_ca_mode = "GOOGLE_MANAGED_CAS_CA"
4836-
server_certificate_rotation_mode = "%s"
4837-
}
4838-
}
4839-
}
4840-
`, databaseName, rotationMode)
4841-
}
4842-
48434789
func testGoogleSqlDatabaseInstance_setSslOptionsForPostgreSQL(databaseName string, databaseVersion string, sslMode string) string {
48444790
return fmt.Sprintf(`
48454791
resource "google_sql_database_instance" "instance" {

mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,6 @@ This setting can be updated, but it cannot be removed after it is set.
534534

535535
* `server_ca_pool` - (Optional) The resource name of the server CA pool for an instance with `CUSTOMER_MANAGED_CAS_CA` as the `server_ca_mode`.
536536

537-
* `server_certificate_rotation_mode` - (Optional) Controls the automatic server certificate rotation feature. Supported values are `NO_AUTOMATIC_ROTATION`and `AUTOMATIC_ROTATION_DURING_MAINTENANCE`. `AUTOMATIC_ROTATION_DURING_MAINTENANCE` can only be set if `server_ca_mode` is either `GOOGLE_MANAGED_CAS_CA` or `CUSTOMER_MANAGED_CAS_CA`. See [API reference doc](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/instances#ipconfiguration) for details.
538-
539537
* `custom_subject_alternative_names` - (Optional) The custom subject alternative names for an instance with `CUSTOMER_MANAGED_CAS_CA` as the `server_ca_mode`.
540538

541539
* `allocated_ip_range` - (Optional) The name of the allocated ip range for the private ip CloudSQL instance. For example: "google-managed-services-default". If set, the instance ip will be created in the allocated range. The range name must comply with [RFC 1035](https://datatracker.ietf.org/doc/html/rfc1035). Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])?.

0 commit comments

Comments
 (0)