@@ -1537,3 +1537,236 @@ data "google_project" "project" {
15371537}
15381538` , context )
15391539}
1540+
1541+ func TestAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabled (t * testing.T ) {
1542+ t .Parallel ()
1543+
1544+ context := map [string ]interface {}{
1545+ "random_suffix" : acctest .RandString (t , 10 ),
1546+ "location" : "us-central1" ,
1547+ }
1548+
1549+ acctest .VcrTest (t , resource.TestCase {
1550+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
1551+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
1552+ CheckDestroy : testAccCheckMemorystoreInstanceDestroyProducer (t ),
1553+ Steps : []resource.TestStep {
1554+ {
1555+ Config : testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabled_bothConnections (context ),
1556+ },
1557+ {
1558+ ResourceName : "google_memorystore_instance.instance-cluster-disabled" ,
1559+ ImportState : true ,
1560+ ImportStateVerify : true ,
1561+ ImportStateVerifyIgnore : []string {"desired_auto_created_endpoints.#" , "desired_auto_created_endpoints.0.%" , "desired_auto_created_endpoints.0.project_id" , "desired_auto_created_endpoints.0.network" , "desired_psc_auto_connections.#" , "desired_psc_auto_connections.0.%" , "desired_psc_auto_connections.0.network" , "desired_psc_auto_connections.0.project_id" },
1562+ },
1563+ {
1564+ Config : testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabledPscAutoConnections (context ),
1565+ },
1566+ {
1567+ ResourceName : "google_memorystore_instance.instance-cluster-disabled" ,
1568+ ImportState : true ,
1569+ ImportStateVerify : true ,
1570+ ImportStateVerifyIgnore : []string {"desired_auto_created_endpoints.#" , "desired_auto_created_endpoints.0.%" , "desired_auto_created_endpoints.0.project_id" , "desired_auto_created_endpoints.0.network" , "desired_psc_auto_connections.#" , "desired_psc_auto_connections.0.%" , "desired_psc_auto_connections.0.network" , "desired_psc_auto_connections.0.project_id" },
1571+ },
1572+ {
1573+ Config : testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabled_onlyAutoCreatedEndpoints (context ),
1574+ },
1575+ {
1576+ ResourceName : "google_memorystore_instance.instance-cluster-disabled" ,
1577+ ImportState : true ,
1578+ ImportStateVerify : true ,
1579+ ImportStateVerifyIgnore : []string {"desired_auto_created_endpoints.#" , "desired_auto_created_endpoints.0.%" , "desired_auto_created_endpoints.0.project_id" , "desired_auto_created_endpoints.0.network" , "desired_psc_auto_connections.#" , "desired_psc_auto_connections.0.%" , "desired_psc_auto_connections.0.network" , "desired_psc_auto_connections.0.project_id" },
1580+ },
1581+ {
1582+ Config : testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabled_neitherConnection (context ),
1583+ },
1584+ {
1585+ ResourceName : "google_memorystore_instance.instance-cluster-disabled" ,
1586+ ImportState : true ,
1587+ ImportStateVerify : true ,
1588+ ImportStateVerifyIgnore : []string {"desired_auto_created_endpoints.#" , "desired_auto_created_endpoints.0.%" , "desired_auto_created_endpoints.0.project_id" , "desired_auto_created_endpoints.0.network" , "desired_psc_auto_connections.#" , "desired_psc_auto_connections.0.%" , "desired_psc_auto_connections.0.network" , "desired_psc_auto_connections.0.project_id" },
1589+ },
1590+ },
1591+ })
1592+ }
1593+
1594+ func testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabledPscAutoConnections (context map [string ]interface {}) string {
1595+ return acctest .Nprintf (`
1596+ resource "google_memorystore_instance" "instance-cluster-disabled" {
1597+ instance_id = "tf-test-instance-psc%{random_suffix}"
1598+ shard_count = 1
1599+ desired_psc_auto_connections {
1600+ network = google_compute_network.producer_net.id
1601+ project_id = data.google_project.project.project_id
1602+ }
1603+ location = "%{location}"
1604+ deletion_protection_enabled = false
1605+ mode = "CLUSTER_DISABLED"
1606+ depends_on = [
1607+ google_network_connectivity_service_connection_policy.default
1608+ ]
1609+ }
1610+
1611+ resource "google_network_connectivity_service_connection_policy" "default" {
1612+ name = "tf-test-my-policy%{random_suffix}"
1613+ location = "%{location}"
1614+ service_class = "gcp-memorystore"
1615+ description = "my basic service connection policy"
1616+ network = google_compute_network.producer_net.id
1617+ psc_config {
1618+ subnetworks = [google_compute_subnetwork.producer_subnet.id]
1619+ }
1620+ }
1621+
1622+ resource "google_compute_subnetwork" "producer_subnet" {
1623+ name = "tf-test-my-subnet%{random_suffix}"
1624+ ip_cidr_range = "10.0.0.248/29"
1625+ region = "%{location}"
1626+ network = google_compute_network.producer_net.id
1627+ }
1628+
1629+ resource "google_compute_network" "producer_net" {
1630+ name = "tf-test-my-network%{random_suffix}"
1631+ auto_create_subnetworks = false
1632+ }
1633+
1634+ data "google_project" "project" {
1635+ }
1636+ ` , context )
1637+ }
1638+
1639+ func testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabled_bothConnections (context map [string ]interface {}) string {
1640+ return acctest .Nprintf (`
1641+ resource "google_memorystore_instance" "instance-cluster-disabled" {
1642+ instance_id = "tf-test-instance-psc%{random_suffix}"
1643+ shard_count = 1
1644+ desired_psc_auto_connections {
1645+ network = google_compute_network.producer_net.id
1646+ project_id = data.google_project.project.project_id
1647+ }
1648+ desired_auto_created_endpoints {
1649+ network = google_compute_network.producer_net.id
1650+ project_id = data.google_project.project.project_id
1651+ }
1652+ location = "%{location}"
1653+ deletion_protection_enabled = false
1654+ mode = "CLUSTER_DISABLED"
1655+ depends_on = [
1656+ google_network_connectivity_service_connection_policy.default
1657+ ]
1658+ }
1659+
1660+ resource "google_network_connectivity_service_connection_policy" "default" {
1661+ name = "tf-test-my-policy%{random_suffix}"
1662+ location = "%{location}"
1663+ service_class = "gcp-memorystore"
1664+ description = "my basic service connection policy"
1665+ network = google_compute_network.producer_net.id
1666+ psc_config {
1667+ subnetworks = [google_compute_subnetwork.producer_subnet.id]
1668+ }
1669+ }
1670+
1671+ resource "google_compute_subnetwork" "producer_subnet" {
1672+ name = "tf-test-my-subnet%{random_suffix}"
1673+ ip_cidr_range = "10.0.0.248/29"
1674+ region = "%{location}"
1675+ network = google_compute_network.producer_net.id
1676+ }
1677+
1678+ resource "google_compute_network" "producer_net" {
1679+ name = "tf-test-my-network%{random_suffix}"
1680+ auto_create_subnetworks = false
1681+ }
1682+
1683+ data "google_project" "project" {
1684+ }
1685+ ` , context )
1686+ }
1687+
1688+ func testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabled_onlyAutoCreatedEndpoints (context map [string ]interface {}) string {
1689+ return acctest .Nprintf (`
1690+ resource "google_memorystore_instance" "instance-cluster-disabled" {
1691+ instance_id = "tf-test-instance-psc%{random_suffix}"
1692+ shard_count = 1
1693+ desired_auto_created_endpoints {
1694+ network = google_compute_network.producer_net.id
1695+ project_id = data.google_project.project.project_id
1696+ }
1697+ location = "%{location}"
1698+ deletion_protection_enabled = false
1699+ mode = "CLUSTER_DISABLED"
1700+ depends_on = [
1701+ google_network_connectivity_service_connection_policy.default
1702+ ]
1703+ }
1704+
1705+ resource "google_network_connectivity_service_connection_policy" "default" {
1706+ name = "tf-test-my-policy%{random_suffix}"
1707+ location = "%{location}"
1708+ service_class = "gcp-memorystore"
1709+ description = "my basic service connection policy"
1710+ network = google_compute_network.producer_net.id
1711+ psc_config {
1712+ subnetworks = [google_compute_subnetwork.producer_subnet.id]
1713+ }
1714+ }
1715+
1716+ resource "google_compute_subnetwork" "producer_subnet" {
1717+ name = "tf-test-my-subnet%{random_suffix}"
1718+ ip_cidr_range = "10.0.0.248/29"
1719+ region = "%{location}"
1720+ network = google_compute_network.producer_net.id
1721+ }
1722+
1723+ resource "google_compute_network" "producer_net" {
1724+ name = "tf-test-my-network%{random_suffix}"
1725+ auto_create_subnetworks = false
1726+ }
1727+
1728+ data "google_project" "project" {
1729+ }
1730+ ` , context )
1731+ }
1732+
1733+ func testAccMemorystoreInstance_memorystorePscAutoInstanceClusterDisabled_neitherConnection (context map [string ]interface {}) string {
1734+ return acctest .Nprintf (`
1735+ resource "google_memorystore_instance" "instance-cluster-disabled" {
1736+ instance_id = "tf-test-instance-psc%{random_suffix}"
1737+ shard_count = 1
1738+ location = "%{location}"
1739+ deletion_protection_enabled = false
1740+ mode = "CLUSTER_DISABLED"
1741+ depends_on = [
1742+ google_network_connectivity_service_connection_policy.default
1743+ ]
1744+ }
1745+
1746+ resource "google_network_connectivity_service_connection_policy" "default" {
1747+ name = "tf-test-my-policy%{random_suffix}"
1748+ location = "%{location}"
1749+ service_class = "gcp-memorystore"
1750+ description = "my basic service connection policy"
1751+ network = google_compute_network.producer_net.id
1752+ psc_config {
1753+ subnetworks = [google_compute_subnetwork.producer_subnet.id]
1754+ }
1755+ }
1756+
1757+ resource "google_compute_subnetwork" "producer_subnet" {
1758+ name = "tf-test-my-subnet%{random_suffix}"
1759+ ip_cidr_range = "10.0.0.248/29"
1760+ region = "%{location}"
1761+ network = google_compute_network.producer_net.id
1762+ }
1763+
1764+ resource "google_compute_network" "producer_net" {
1765+ name = "tf-test-my-network%{random_suffix}"
1766+ auto_create_subnetworks = false
1767+ }
1768+
1769+ data "google_project" "project" {
1770+ }
1771+ ` , context )
1772+ }
0 commit comments