Skip to content

Commit e831e5e

Browse files
Revert "feat: support PSC outbound's network attachment field" (#14533) (#10355)
[upstream:95927b93ff81923ab376c5e2abbd283827202261] Signed-off-by: Modular Magician <[email protected]>
1 parent f89875f commit e831e5e

File tree

3 files changed

+0
-207
lines changed

3 files changed

+0
-207
lines changed

google-beta/services/sql/resource_sql_database_instance.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,6 @@ is set to true. Defaults to ZONAL.`,
546546
Set: schema.HashString,
547547
Description: `List of consumer projects that are allow-listed for PSC connections to this instance. This instance can be connected to with PSC from any network in these projects. Each consumer project in this list may be represented by a project number (numeric) or by a project id (alphanumeric).`,
548548
},
549-
"network_attachment_uri": {
550-
Type: schema.TypeString,
551-
Optional: true,
552-
Description: `Name of network attachment resource used to authorize a producer service to connect a PSC interface to the consumer's VPC. For example: "projects/myProject/regions/myRegion/networkAttachments/myNetworkAttachment". This is required to enable outbound connection on a PSC instance.`,
553-
},
554549
"psc_auto_connections": {
555550
Type: schema.TypeList,
556551
Optional: true,
@@ -1612,7 +1607,6 @@ func expandPscConfig(configured []interface{}) *sqladmin.PscConfig {
16121607
return &sqladmin.PscConfig{
16131608
PscEnabled: _entry["psc_enabled"].(bool),
16141609
AllowedConsumerProjects: tpgresource.ConvertStringArr(_entry["allowed_consumer_projects"].(*schema.Set).List()),
1615-
NetworkAttachmentUri: _entry["network_attachment_uri"].(string),
16161610
PscAutoConnections: expandPscAutoConnectionConfig(_entry["psc_auto_connections"].([]interface{})),
16171611
}
16181612
}
@@ -2656,7 +2650,6 @@ func flattenPscConfigs(pscConfig *sqladmin.PscConfig) interface{} {
26562650
data := map[string]interface{}{
26572651
"psc_enabled": pscConfig.PscEnabled,
26582652
"allowed_consumer_projects": schema.NewSet(schema.HashString, tpgresource.ConvertStringArrToInterface(pscConfig.AllowedConsumerProjects)),
2659-
"network_attachment_uri": pscConfig.NetworkAttachmentUri,
26602653
"psc_auto_connections": flattenPscAutoConnections(pscConfig.PscAutoConnections),
26612654
}
26622655

google-beta/services/sql/resource_sql_database_instance_test.go

Lines changed: 0 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,84 +1193,6 @@ func TestAccSqlDatabaseInstance_withPSCEnabled_withIpV4Enabled(t *testing.T) {
11931193
})
11941194
}
11951195

1196-
func TestAccSqlDatabaseInstance_withPscEnabled_withNetworkAttachmentUri_thenRemoveNetworkAttachment(t *testing.T) {
1197-
t.Parallel()
1198-
1199-
random_suffix := acctest.RandString(t, 10)
1200-
instanceName := "tf-test-" + random_suffix
1201-
projectId := envvar.GetTestProjectFromEnv()
1202-
region := "us-central1"
1203-
networkNameStr := "tf-test-cloud-sql-network-" + random_suffix
1204-
subnetworkNameStr := "tf-test-cloud-sql-subnetwork-" + random_suffix
1205-
networkAttachmentNameStr := "tf-test-cloud-sql-update-na-" + random_suffix
1206-
networkName := acctest.BootstrapSharedTestNetwork(t, networkNameStr)
1207-
subnetworkName := acctest.BootstrapSubnet(t, subnetworkNameStr, networkName)
1208-
networkAttachmentName := acctest.BootstrapNetworkAttachment(t, networkAttachmentNameStr, subnetworkName)
1209-
networkAttachmentUri := fmt.Sprintf("projects/%s/regions/%s/networkAttachments/%s", projectId, region, networkAttachmentName)
1210-
1211-
acctest.VcrTest(t, resource.TestCase{
1212-
PreCheck: func() { acctest.AccTestPreCheck(t) },
1213-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1214-
CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t),
1215-
Steps: []resource.TestStep{
1216-
{
1217-
Config: testAccSqlDatabaseInstance_withPSCEnabled_withoutPscOutbound(instanceName),
1218-
Check: resource.ComposeTestCheckFunc(verifyPscNetorkAttachmentOperation("google_sql_database_instance.instance", true, true, "")),
1219-
},
1220-
{
1221-
ResourceName: "google_sql_database_instance.instance",
1222-
ImportState: true,
1223-
ImportStateVerify: true,
1224-
ImportStateIdPrefix: fmt.Sprintf("%s/", projectId),
1225-
ImportStateVerifyIgnore: []string{"deletion_protection"},
1226-
},
1227-
{
1228-
Config: testAccSqlDatabaseInstance_withPSCEnabled_withNetworkAttachmentUri(instanceName, networkAttachmentUri),
1229-
Check: resource.ComposeTestCheckFunc(verifyPscNetorkAttachmentOperation("google_sql_database_instance.instance", true, true, networkAttachmentUri)),
1230-
},
1231-
{
1232-
ResourceName: "google_sql_database_instance.instance",
1233-
ImportState: true,
1234-
ImportStateVerify: true,
1235-
ImportStateIdPrefix: fmt.Sprintf("%s/", projectId),
1236-
ImportStateVerifyIgnore: []string{"deletion_protection"},
1237-
},
1238-
{
1239-
Config: testAccSqlDatabaseInstance_withPSCEnabled_withoutPscOutbound(instanceName),
1240-
Check: resource.ComposeTestCheckFunc(verifyPscNetorkAttachmentOperation("google_sql_database_instance.instance", true, true, "")),
1241-
},
1242-
},
1243-
})
1244-
}
1245-
1246-
func TestAccSqlDatabaseInstance_withPscEnabled_withNetworkAttachmentUriOnCreate(t *testing.T) {
1247-
t.Parallel()
1248-
1249-
random_suffix := acctest.RandString(t, 10)
1250-
instanceName := "tf-test-" + random_suffix
1251-
projectId := envvar.GetTestProjectFromEnv()
1252-
region := "us-central1"
1253-
networkNameStr := "tf-test-cloud-sql-network-" + random_suffix
1254-
subnetworkNameStr := "tf-test-cloud-sql-subnetwork-" + random_suffix
1255-
networkAttachmentNameStr := "tf-test-cloud-sql-update-na-" + random_suffix
1256-
networkName := acctest.BootstrapSharedTestNetwork(t, networkNameStr)
1257-
subnetworkName := acctest.BootstrapSubnet(t, subnetworkNameStr, networkName)
1258-
networkAttachmentName := acctest.BootstrapNetworkAttachment(t, networkAttachmentNameStr, subnetworkName)
1259-
networkAttachmentUri := fmt.Sprintf("projects/%s/regions/%s/networkAttachments/%s", projectId, region, networkAttachmentName)
1260-
1261-
acctest.VcrTest(t, resource.TestCase{
1262-
PreCheck: func() { acctest.AccTestPreCheck(t) },
1263-
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1264-
CheckDestroy: testAccSqlDatabaseInstanceDestroyProducer(t),
1265-
Steps: []resource.TestStep{
1266-
{
1267-
Config: testAccSqlDatabaseInstance_withPSCEnabled_withNetworkAttachmentUri(instanceName, networkAttachmentUri),
1268-
ExpectError: regexp.MustCompile(`.*Network attachment used for Private Service Connect interfaces can not be assigned with instance creation.*`),
1269-
},
1270-
},
1271-
})
1272-
}
1273-
12741196
func TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange(t *testing.T) {
12751197

12761198
t.Parallel()
@@ -4931,49 +4853,6 @@ func verifyPscAutoConnectionsOperation(resourceName string, isPscConfigExpected
49314853
}
49324854
}
49334855

4934-
func verifyPscNetorkAttachmentOperation(resourceName string, isPscConfigExpected bool, expectedPscEnabled bool, expectedNetworkAttachmentUri string) func(*terraform.State) error {
4935-
return func(s *terraform.State) error {
4936-
resource, ok := s.RootModule().Resources[resourceName]
4937-
if !ok {
4938-
return fmt.Errorf("Can't find %s in state", resourceName)
4939-
}
4940-
4941-
resourceAttributes := resource.Primary.Attributes
4942-
_, ok = resourceAttributes["settings.0.ip_configuration.#"]
4943-
if !ok {
4944-
return fmt.Errorf("settings.0.ip_configuration.# block is not present in state for %s", resourceName)
4945-
}
4946-
4947-
if isPscConfigExpected {
4948-
_, ok := resourceAttributes["settings.0.ip_configuration.0.psc_config.#"]
4949-
if !ok {
4950-
return fmt.Errorf("settings.0.ip_configuration.0.psc_config property is not present or set in state of %s", resourceName)
4951-
}
4952-
4953-
pscEnabledStr, ok := resourceAttributes["settings.0.ip_configuration.0.psc_config.0.psc_enabled"]
4954-
pscEnabled, err := strconv.ParseBool(pscEnabledStr)
4955-
if err != nil || pscEnabled != expectedPscEnabled {
4956-
return fmt.Errorf("settings.0.ip_configuration.0.psc_config.0.psc_enabled property value is not set as expected in state of %s, expected %v, actual %v", resourceName, expectedPscEnabled, pscEnabled)
4957-
}
4958-
4959-
networkAttachmentUriStr, ok := resourceAttributes["settings.0.ip_configuration.0.psc_config.0.network_attachment_uri"]
4960-
if !ok {
4961-
return fmt.Errorf("settings.0.ip_configuration.0.psc_config.0.network_attachment_uri block is not present in state for %s", resourceName)
4962-
}
4963-
4964-
if networkAttachmentUriStr != expectedNetworkAttachmentUri && len(networkAttachmentUriStr) == 0 {
4965-
return fmt.Errorf("settings.0.ip_configuration.0.psc_config.0.network_attachment_uri block is not set in state for %s", resourceName)
4966-
}
4967-
4968-
if networkAttachmentUriStr != expectedNetworkAttachmentUri {
4969-
return fmt.Errorf("settings.0.ip_configuration.0.psc_config.0.network_attachment_uri block does not match the expected value for %s", resourceName)
4970-
}
4971-
}
4972-
4973-
return nil
4974-
}
4975-
}
4976-
49774856
func testAccSqlDatabaseInstance_withoutMCPEnabled(instanceName string) string {
49784857
return fmt.Sprintf(`
49794858
resource "google_sql_database_instance" "instance" {
@@ -5034,32 +4913,6 @@ resource "google_sql_database_instance" "instance" {
50344913
`, instanceName)
50354914
}
50364915

5037-
func testAccSqlDatabaseInstance_withPSCEnabled_withoutPscOutbound(instanceName string) string {
5038-
return fmt.Sprintf(`
5039-
resource "google_sql_database_instance" "instance" {
5040-
name = "%s"
5041-
region = "us-central1"
5042-
database_version = "MYSQL_8_0"
5043-
deletion_protection = false
5044-
settings {
5045-
tier = "db-g1-small"
5046-
ip_configuration {
5047-
psc_config {
5048-
psc_enabled = true
5049-
network_attachment_uri = ""
5050-
}
5051-
ipv4_enabled = false
5052-
}
5053-
backup_configuration {
5054-
enabled = true
5055-
binary_log_enabled = true
5056-
}
5057-
availability_type = "REGIONAL"
5058-
}
5059-
}
5060-
`, instanceName)
5061-
}
5062-
50634916
func testAccSqlDatabaseInstance_withPSCEnabled_withPscAutoConnections(instanceName string, projectId string, networkName string) string {
50644917
return fmt.Sprintf(`
50654918
data "google_compute_network" "testnetwork" {
@@ -5093,32 +4946,6 @@ resource "google_sql_database_instance" "instance" {
50934946
`, networkName, instanceName, projectId, networkName, projectId)
50944947
}
50954948

5096-
func testAccSqlDatabaseInstance_withPSCEnabled_withNetworkAttachmentUri(instanceName string, networkAttachmentUri string) string {
5097-
return fmt.Sprintf(`
5098-
5099-
resource "google_sql_database_instance" "instance" {
5100-
name = "%s"
5101-
region = "us-central1"
5102-
database_version = "MYSQL_8_0"
5103-
deletion_protection = false
5104-
settings {
5105-
tier = "db-g1-small"
5106-
ip_configuration {
5107-
psc_config {
5108-
psc_enabled = true
5109-
network_attachment_uri = "%s"
5110-
}
5111-
ipv4_enabled = false
5112-
}
5113-
backup_configuration {
5114-
enabled = true
5115-
binary_log_enabled = true
5116-
}
5117-
availability_type = "REGIONAL"
5118-
}
5119-
}`, instanceName, networkAttachmentUri)
5120-
}
5121-
51224949
func testAccSqlDatabaseInstance_withPrivateNetwork_withoutAllocatedIpRange(databaseName, networkName string, specifyPrivatePathOption bool, enablePrivatePath bool) string {
51234950
privatePathOption := ""
51244951
if specifyPrivatePathOption {

website/docs/r/sql_database_instance.html.markdown

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -258,31 +258,6 @@ resource "google_sql_database_instance" "main" {
258258
}
259259
```
260260

261-
### Cloud SQL Instance with PSC outbound
262-
263-
```hcl
264-
resource "google_sql_database_instance" "main" {
265-
name = "psc-enabled-main-instance"
266-
database_version = "MYSQL_8_0"
267-
settings {
268-
tier = "db-f1-micro"
269-
ip_configuration {
270-
psc_config {
271-
psc_enabled = true
272-
allowed_consumer_projects = ["allowed-consumer-project-name"]
273-
network_attachment_uri = "network-attachment-uri"
274-
}
275-
ipv4_enabled = false
276-
}
277-
backup_configuration {
278-
enabled = true
279-
binary_log_enabled = true
280-
}
281-
availability_type = "REGIONAL"
282-
}
283-
}
284-
```
285-
286261
## Argument Reference
287262

288263
The following arguments are supported:
@@ -504,8 +479,6 @@ The optional `settings.ip_configuration.psc_config` sublist supports:
504479

505480
* `consumer_network` - "The consumer network of this consumer endpoint. This must be a resource path that includes both the host project and the network name. For example, `projects/project1/global/networks/network1`. The consumer host project of this network might be different from the consumer service project."
506481

507-
* `network_attachment_uri` - (Optional) Network Attachment URI in the format `projects/project1/regions/region1/networkAttachments/networkAttachment1` to enable outbound connectivity on PSC instance.
508-
509482
* `consumer_service_project_id` - (Optional) The project ID of consumer service project of this consumer endpoint.
510483

511484
The optional `settings.location_preference` subblock supports:

0 commit comments

Comments
 (0)