diff --git a/internal/service/gateway/gateway.go b/internal/service/gateway/gateway.go index d68cfd285..b299d381d 100644 --- a/internal/service/gateway/gateway.go +++ b/internal/service/gateway/gateway.go @@ -34,11 +34,13 @@ const ( func ResourceGateway() *schema.Resource { return &schema.Resource{ - Description: "Network gateways connect SDN Private Networks to external IP networks.", - CreateContext: resourceGatewayCreate, - ReadContext: resourceGatewayRead, - UpdateContext: resourceGatewayUpdate, - DeleteContext: resourceGatewayDelete, + EnableLegacyTypeSystemApplyErrors: true, + EnableLegacyTypeSystemPlanErrors: true, + Description: "Network gateways connect SDN Private Networks to external IP networks.", + CreateContext: resourceGatewayCreate, + ReadContext: resourceGatewayRead, + UpdateContext: resourceGatewayUpdate, + DeleteContext: resourceGatewayDelete, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, @@ -73,6 +75,8 @@ func ResourceGateway() *schema.Resource { MaxItems: 1, MinItems: 1, Elem: &schema.Resource{ + EnableLegacyTypeSystemApplyErrors: true, + EnableLegacyTypeSystemPlanErrors: true, Schema: map[string]*schema.Schema{ "id": { Description: routerIDDescription, @@ -108,6 +112,8 @@ func ResourceGateway() *schema.Resource { Type: schema.TypeSet, MaxItems: 1, Elem: &schema.Resource{ + EnableLegacyTypeSystemApplyErrors: true, + EnableLegacyTypeSystemPlanErrors: true, Schema: map[string]*schema.Schema{ "address": { Type: schema.TypeString, @@ -140,6 +146,8 @@ func ResourceGateway() *schema.Resource { Computed: true, Type: schema.TypeSet, Elem: &schema.Resource{ + EnableLegacyTypeSystemApplyErrors: true, + EnableLegacyTypeSystemPlanErrors: true, Schema: map[string]*schema.Schema{ "address": { Type: schema.TypeString, diff --git a/upcloud/resource_upcloud_gateway_test.go b/upcloud/resource_upcloud_gateway_test.go index 376b7369f..117ebf97f 100644 --- a/upcloud/resource_upcloud_gateway_test.go +++ b/upcloud/resource_upcloud_gateway_test.go @@ -157,6 +157,36 @@ func TestAccUpcloudGateway(t *testing.T) { }) } +func TestAccUpcloudGateway_Minimal(t *testing.T) { + testData := utils.ReadTestDataFile(t, "testdata/upcloud_gateway/gateway_minimal.tf") + name := "upcloud_gateway.this" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: testAccProviderFactories, + Steps: []resource.TestStep{ + { + Config: testData, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(name, "name", "tf-acc-test-net-gateway-gw"), + resource.TestCheckResourceAttr(name, "zone", "pl-waw1"), + ), + }, + { + Config: testData, + PlanOnly: true, + ExpectNonEmptyPlan: false, + }, + { + Config: testData, + ResourceName: name, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccUpcloudGateway_LabelsValidation(t *testing.T) { testDataE := utils.ReadTestDataFile(t, "testdata/upcloud_gateway/gateway_e.tf") diff --git a/upcloud/testdata/upcloud_gateway/gateway_minimal.tf b/upcloud/testdata/upcloud_gateway/gateway_minimal.tf new file mode 100644 index 000000000..0b3cff8dc --- /dev/null +++ b/upcloud/testdata/upcloud_gateway/gateway_minimal.tf @@ -0,0 +1,40 @@ +variable "prefix" { + default = "tf-acc-test-net-gateway-" + type = string +} + +variable "zone" { + default = "pl-waw1" + type = string +} + +resource "upcloud_router" "this" { + name = "${var.prefix}router" + + lifecycle { + ignore_changes = [static_route] + } +} + +resource "upcloud_network" "this" { + name = "${var.prefix}net" + zone = var.zone + + ip_network { + address = "172.16.125.0/24" + dhcp = true + family = "IPv4" + } + + router = upcloud_router.this.id +} + +resource "upcloud_gateway" "this" { + name = "${var.prefix}gw" + zone = var.zone + features = ["nat"] + + router { + id = upcloud_router.this.id + } +}