From 9a5e0dd8ea59d0b773d07db5d51cf7634c01bb51 Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar Date: Thu, 17 Apr 2025 13:16:36 +0530 Subject: [PATCH 1/2] Update resource_ibm_is_vpn_gateway_connections.go --- ibm/service/vpc/resource_ibm_is_vpn_gateway_connections.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ibm/service/vpc/resource_ibm_is_vpn_gateway_connections.go b/ibm/service/vpc/resource_ibm_is_vpn_gateway_connections.go index 1425bf946b..b7fdd3bbe1 100644 --- a/ibm/service/vpc/resource_ibm_is_vpn_gateway_connections.go +++ b/ibm/service/vpc/resource_ibm_is_vpn_gateway_connections.go @@ -204,6 +204,7 @@ func ResourceIBMISVPNGatewayConnection() *schema.Resource { isVPNGatewayConnectionPreSharedKey: { Type: schema.TypeString, Required: true, + Sensitive: true, Description: "vpn gateway", }, From a4d14e13b53f110f2ff6c41a02f8f52e0d018cdf Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar Date: Thu, 17 Apr 2025 13:42:16 +0530 Subject: [PATCH 2/2] Update resource_ibm_is_vpn_gateway_connection_test.go --- ...urce_ibm_is_vpn_gateway_connection_test.go | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/ibm/service/vpc/resource_ibm_is_vpn_gateway_connection_test.go b/ibm/service/vpc/resource_ibm_is_vpn_gateway_connection_test.go index 8f79ff27d3..070f6112c8 100644 --- a/ibm/service/vpc/resource_ibm_is_vpn_gateway_connection_test.go +++ b/ibm/service/vpc/resource_ibm_is_vpn_gateway_connection_test.go @@ -1646,3 +1646,70 @@ func testAccCheckIBMISVPNGatewayConnectionCIDRConfig(vpc, subnet1, subnet2, vpnn } `, name) } + +func TestAccIBMISVPNGatewayConnection_sensitive(t *testing.T) { + var VPNGatewayConnection string + vpcname := fmt.Sprintf("tfvpngc-vpc-%d", acctest.RandIntRange(10, 100)) + subnetname := fmt.Sprintf("tfvpngc-subnet-%d", acctest.RandIntRange(10, 100)) + vpnname := fmt.Sprintf("tfvpngc-vpn-%d", acctest.RandIntRange(10, 100)) + connectionName := fmt.Sprintf("tfvpngc-conn-%d", acctest.RandIntRange(10, 100)) + presharedKey := fmt.Sprintf("tfvpngc-psk-%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMISVPNGatewayConnectionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMISVPNGatewayConnectionSensitiveConfig(vpcname, subnetname, vpnname, connectionName, presharedKey), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMISVPNGatewayConnectionExists("ibm_is_vpn_gateway_connection.testacc_vpn_connection", VPNGatewayConnection), + resource.TestCheckResourceAttr( + "ibm_is_vpn_gateway_connection.testacc_vpn_connection", "name", connectionName), + resource.TestCheckResourceAttr( + "ibm_is_vpn_gateway_connection.testacc_vpn_connection", "preshared_key", presharedKey), + resource.TestCheckResourceAttrSet( + "ibm_is_vpn_gateway_connection.testacc_vpn_connection", "status"), + ), + }, + // Import step to verify resource can be imported + { + ResourceName: "ibm_is_vpn_gateway_connection.testacc_vpn_connection", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"preshared_key", "local_cidrs", + "peer_cidrs", + "vpn_gateway"}, + }, + }, + }) +} + +func testAccCheckIBMISVPNGatewayConnectionSensitiveConfig(vpc, subnet, vpnname, connName, psk string) string { + return fmt.Sprintf(` + resource "ibm_is_vpc" "testacc_vpc" { + name = "%s" + } + + resource "ibm_is_subnet" "testacc_subnet" { + name = "%s" + vpc = ibm_is_vpc.testacc_vpc.id + zone = "%s" + ipv4_cidr_block = "%s" + } + + resource "ibm_is_vpn_gateway" "testacc_vpn_gateway" { + name = "%s" + subnet = ibm_is_subnet.testacc_subnet.id + } + + resource "ibm_is_vpn_gateway_connection" "testacc_vpn_connection" { + name = "%s" + vpn_gateway = ibm_is_vpn_gateway.testacc_vpn_gateway.id + peer_address = "1.2.3.4" + preshared_key = "%s" + local_cidrs = [ibm_is_subnet.testacc_subnet.ipv4_cidr_block] + peer_cidrs = ["192.168.0.0/24"] + } + `, vpc, subnet, acc.ISZoneName, acc.ISCIDR, vpnname, connName, psk) +}