diff --git a/nsxt/resource_nsxt_policy_transit_gateway_attachment_test.go b/nsxt/resource_nsxt_policy_transit_gateway_attachment_test.go index 8dd6e0392..ab3ea6aa9 100644 --- a/nsxt/resource_nsxt_policy_transit_gateway_attachment_test.go +++ b/nsxt/resource_nsxt_policy_transit_gateway_attachment_test.go @@ -166,16 +166,15 @@ resource "nsxt_policy_project" "test" { tgw_external_connections = [nsxt_policy_gateway_connection.test.path] } -resource "nsxt_policy_transit_gateway" "test" { +data "nsxt_policy_transit_gateway" "test" { context { project_id = nsxt_policy_project.test.id } - display_name = "%s" - transit_subnets = ["192.168.7.0/24"] + id = "default" } resource "nsxt_policy_transit_gateway_attachment" "test" { - parent_path = nsxt_policy_transit_gateway.test.path + parent_path = data.nsxt_policy_transit_gateway.test.path connection_path = nsxt_policy_gateway_connection.test.path display_name = "%s" description = "%s" @@ -184,5 +183,5 @@ resource "nsxt_policy_transit_gateway_attachment" "test" { scope = "scope1" tag = "tag1" } -}`, getEdgeClusterName(), dependantEntityName, dependantEntityName, dependantEntityName, dependantEntityName, attrMap["display_name"], attrMap["description"]) +}`, getEdgeClusterName(), dependantEntityName, dependantEntityName, dependantEntityName, attrMap["display_name"], attrMap["description"]) } diff --git a/nsxt/resource_nsxt_policy_transit_gateway_nat_rule_test.go b/nsxt/resource_nsxt_policy_transit_gateway_nat_rule_test.go index d30052625..da00b1b5a 100644 --- a/nsxt/resource_nsxt_policy_transit_gateway_nat_rule_test.go +++ b/nsxt/resource_nsxt_policy_transit_gateway_nat_rule_test.go @@ -245,7 +245,7 @@ resource "nsxt_policy_transit_gateway" "test" { } data "nsxt_policy_transit_gateway_nat" "test" { - transit_gateway_path = nsxt_policy_transit_gateway.test.path + transit_gateway_path = data.nsxt_policy_transit_gateway.test.path } `, testAccNsxtProjectContext(), accTestTransitGatewayNatRuleHelperName) } diff --git a/nsxt/resource_nsxt_policy_transit_gateway_test.go b/nsxt/resource_nsxt_policy_transit_gateway_test.go index 4f37524e0..c50f950c5 100644 --- a/nsxt/resource_nsxt_policy_transit_gateway_test.go +++ b/nsxt/resource_nsxt_policy_transit_gateway_test.go @@ -28,7 +28,11 @@ func TestAccResourceNsxtPolicyTransitGateway_basic(t *testing.T) { testDataSourceName := "nsxt_policy_transit_gateway.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); testAccOnlyVPC(t) }, + PreCheck: func() { + testAccPreCheck(t) + testAccOnlyVPC(t) + testAccNSXVersion(t, "9.1.0") + }, Providers: testAccProviders, CheckDestroy: func(state *terraform.State) error { return testAccNsxtPolicyTransitGatewayCheckDestroy(state, accTestTransitGatewayUpdateAttributes["display_name"]) @@ -88,7 +92,11 @@ func TestAccResourceNsxtPolicyTransitGateway_importBasic(t *testing.T) { testResourceName := "nsxt_policy_transit_gateway.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); testAccOnlyVPC(t) }, + PreCheck: func() { + testAccPreCheck(t) + testAccOnlyVPC(t) + testAccNSXVersion(t, "9.1.0") + }, Providers: testAccProviders, CheckDestroy: func(state *terraform.State) error { return testAccNsxtPolicyTransitGatewayCheckDestroy(state, name) diff --git a/nsxt/resource_nsxt_vpc_connectivity_profile_test.go b/nsxt/resource_nsxt_vpc_connectivity_profile_test.go index 4b0287caa..9bee4be6b 100644 --- a/nsxt/resource_nsxt_vpc_connectivity_profile_test.go +++ b/nsxt/resource_nsxt_vpc_connectivity_profile_test.go @@ -169,15 +169,14 @@ func testAccNsxtVpcConnectivityProfileCheckDestroy(state *terraform.State, displ return nil } -var testAccNsxtVpcConnectivityProfileHelper = getAccTestResourceName() - func testAccNsxtVpcConnectivityProfilePrerequisite() string { + //TODO: replace datasource with resource when transit GW creation is enabled return fmt.Sprintf(` -resource "nsxt_policy_transit_gateway" "test" { +data "nsxt_policy_transit_gateway" "test" { %s - display_name = "%s" - transit_subnets = ["192.168.7.0/24"] -}`, testAccNsxtProjectContext(), testAccNsxtVpcConnectivityProfileHelper) + id = "default" +} +`, testAccNsxtProjectContext()) } func testAccNsxtVpcConnectivityProfileTemplate(createFlow bool) string { @@ -192,7 +191,7 @@ resource "nsxt_vpc_connectivity_profile" "test" { %s display_name = "%s" description = "%s" - transit_gateway_path = nsxt_policy_transit_gateway.test.path + transit_gateway_path = data.nsxt_policy_transit_gateway.test.path service_gateway { nat_config { @@ -220,7 +219,7 @@ func testAccNsxtVpcConnectivityProfileMinimalistic() string { resource "nsxt_vpc_connectivity_profile" "test" { %s display_name = "%s" - transit_gateway_path = nsxt_policy_transit_gateway.test.path + transit_gateway_path = data.nsxt_policy_transit_gateway.test.path }`, testAccNsxtProjectContext(), accTestVpcConnectivityProfileUpdateAttributes["display_name"]) } diff --git a/nsxt/resource_nsxt_vpc_test.go b/nsxt/resource_nsxt_vpc_test.go index 094dff973..c135b1d50 100644 --- a/nsxt/resource_nsxt_vpc_test.go +++ b/nsxt/resource_nsxt_vpc_test.go @@ -203,7 +203,7 @@ resource "nsxt_vpc_connectivity_profile" "test" { %s display_name = "%s" - transit_gateway_path = nsxt_policy_transit_gateway.test.path + transit_gateway_path = data.nsxt_policy_transit_gateway.test.path service_gateway { enable = false }