Skip to content
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

Allow ENTERPRISE_PLUS as default Edition for POSTGRES_16 #19977

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/12077.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
sql: removed the client-side default of `ENTERPRISE` for `edition` in `google_sql_database_instance` so that `edition` is determined by the API when unset. This will cause new instances to use `ENTERPRISE_PLUS` as the default for POSTGRES_16.
```
2 changes: 1 addition & 1 deletion google/services/sql/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func ResourceSqlDatabaseInstance() *schema.Resource {
"edition": {
Type: schema.TypeString,
Optional: true,
Default: "ENTERPRISE",
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"ENTERPRISE", "ENTERPRISE_PLUS"}, false),
Description: `The edition of the instance, can be ENTERPRISE or ENTERPRISE_PLUS.`,
},
Expand Down
49 changes: 44 additions & 5 deletions google/services/sql/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,32 @@ func TestAccSQLDatabaseInstance_DenyMaintenancePeriod(t *testing.T) {
})
}

func TestAccSQLDatabaseInstance_DefaultEdition(t *testing.T) {
t.Parallel()
databaseName := "tf-test-" + acctest.RandString(t, 10)
databaseVersion := "POSTGRES_16"
enterprisePlusTier := "db-perf-optimized-N-2"
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testGoogleSqlDatabaseInstance_DefaultEdition(databaseName, databaseVersion, enterprisePlusTier),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("google_sql_database_instance.instance", "settings.0.edition", "ENTERPRISE_PLUS"),
),
},
{
ResourceName: "google_sql_database_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
},
})
}

func TestAccSqlDatabaseInstance_Edition(t *testing.T) {
t.Parallel()
enterprisePlusName := "tf-test-enterprise-plus" + acctest.RandString(t, 10)
Expand Down Expand Up @@ -1757,7 +1783,7 @@ func TestAccSqlDatabaseInstance_Postgres_Edition_Upgrade(t *testing.T) {
CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testGoogleSqlDatabaseInstance_EditionConfig_noEdition(editionUpgrade, enterpriseTier),
Config: testGoogleSqlDatabaseInstance_EditionConfig(editionUpgrade, enterpriseTier, "ENTERPRISE"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("google_sql_database_instance.instance", "settings.0.edition", "ENTERPRISE"),
),
Expand Down Expand Up @@ -1807,7 +1833,7 @@ func TestAccSqlDatabaseInstance_Edition_Downgrade(t *testing.T) {
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
{
Config: testGoogleSqlDatabaseInstance_EditionConfig_noEdition(editionDowngrade, enterpriseTier),
Config: testGoogleSqlDatabaseInstance_EditionConfig(editionDowngrade, enterpriseTier, "ENTERPRISE"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("google_sql_database_instance.instance", "settings.0.edition", "ENTERPRISE"),
),
Expand Down Expand Up @@ -2683,6 +2709,19 @@ resource "google_sql_database_instance" "instance" {
}`, databaseName, endDate, startDate, time)
}

func testGoogleSqlDatabaseInstance_DefaultEdition(databaseName, databaseVersion, tier string) string {
return fmt.Sprintf(`
resource "google_sql_database_instance" "instance" {
name = "%s"
region = "us-east1"
database_version = "%s"
deletion_protection = false
settings {
tier = "%s"
}
}`, databaseName, databaseVersion, tier)
}

func testGoogleSqlDatabaseInstance_EditionConfig_noEdition(databaseName, tier string) string {
return fmt.Sprintf(`

Expand All @@ -2693,9 +2732,6 @@ resource "google_sql_database_instance" "instance" {
deletion_protection = false
settings {
tier = "%s"
backup_configuration {
transaction_log_retention_days = 7
}
}
}`, databaseName, tier)
}
Expand All @@ -2711,6 +2747,9 @@ resource "google_sql_database_instance" "instance" {
settings {
tier = "%s"
edition = "%s"
backup_configuration {
transaction_log_retention_days = 7
}
}
}`, databaseName, tier, edition)
}
Expand Down