Skip to content

Commit 4e840b3

Browse files
committed
chore(container/function): namespace: deprecate activate_vpc_integration attribute
1 parent d888258 commit 4e840b3

File tree

8 files changed

+738
-2306
lines changed

8 files changed

+738
-2306
lines changed

docs/resources/container_namespace.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ The following arguments are supported:
4040

4141
- `secret_environment_variables` - (Optional) The secret environment variables of the namespace.
4242

43-
- `activate_vpc_integration` - (Optional) Activates VPC integration for the namespace. Containers of a namespace with VPC integration activated will be able to connect to a Private Network.
43+
- `activate_vpc_integration` - (Deprecated) Activates VPC integration for the namespace. Containers of a namespace with VPC integration activated will be able to connect to a Private Network.
4444

45-
~> **Important** Updates to `activate_vpc_integration` will recreate the namespace.
45+
~> **Important:** VPC integration is now available on all namespaces, so this field is not configurable anymore and its value will always be "true".
4646

4747
## Attributes Reference
4848

docs/resources/function_namespace.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ The following arguments are supported:
4040

4141
- `secret_environment_variables` - (Optional) The secret environment variables of the namespace.
4242

43-
- `activate_vpc_integration` - (Optional) Activates VPC integration for the namespace. Functions of a namespace with VPC integration activated will be able to connect to a Private Network.
43+
- `activate_vpc_integration` - (Deprecated) Activates VPC integration for the namespace. Functions of a namespace with VPC integration activated will be able to connect to a Private Network.
4444

45-
~> **Important** Updates to `activate_vpc_integration` will recreate the namespace.
45+
~> **Important:** VPC integration is now available on all namespaces, so this field is not configurable anymore and its value will always be "true".
4646

4747
## Attributes Reference
4848

internal/services/container/namespace.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ func ResourceNamespace() *schema.Resource {
9797
},
9898
"activate_vpc_integration": {
9999
Type: schema.TypeBool,
100-
ForceNew: true,
100+
Deprecated: "VPC integration is now available on all namespaces, so this field is not configurable anymore and its value will always be \"true\".",
101101
Optional: true,
102-
Default: false,
102+
Default: true,
103103
Description: "Activate VPC integration for the namespace",
104104
},
105105
"region": regional.Schema(),
@@ -129,10 +129,6 @@ func ResourceContainerNamespaceCreate(ctx context.Context, d *schema.ResourceDat
129129
createReq.Tags = types.ExpandStrings(rawTag)
130130
}
131131

132-
if activateVPC, ok := d.GetOk("activate_vpc_integration"); ok {
133-
createReq.ActivateVpcIntegration = activateVPC.(bool)
134-
}
135-
136132
ns, err := api.CreateNamespace(createReq, scw.WithContext(ctx))
137133
if err != nil {
138134
return diag.FromErr(err)

internal/services/container/namespace_test.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package container_test
22

33
import (
44
"fmt"
5-
"regexp"
65
"testing"
76

87
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -295,24 +294,10 @@ func TestAccNamespace_VPCIntegration(t *testing.T) {
295294
`,
296295
Check: resource.ComposeTestCheckFunc(
297296
isNamespacePresent(tt, "scaleway_container_namespace.main"),
298-
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "activate_vpc_integration", "false"),
297+
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "activate_vpc_integration", "true"),
299298
acctest.CheckResourceIDPersisted("scaleway_container_namespace.main", &namespaceID),
300299
),
301300
},
302-
{
303-
Config: `
304-
resource scaleway_vpc_private_network main {}
305-
306-
resource scaleway_container_namespace main {}
307-
308-
resource scaleway_container main {
309-
namespace_id = scaleway_container_namespace.main.id
310-
private_network_id = scaleway_vpc_private_network.main.id
311-
sandbox = "v1"
312-
}
313-
`,
314-
ExpectError: regexp.MustCompile("Application can't be attached to private network, vpc integration must be activated on its parent namespace"),
315-
},
316301
{
317302
Config: `
318303
resource scaleway_vpc_private_network main {}
@@ -332,7 +317,7 @@ func TestAccNamespace_VPCIntegration(t *testing.T) {
332317
isContainerPresent(tt, "scaleway_container.main"),
333318
resource.TestCheckResourceAttr("scaleway_container_namespace.main", "activate_vpc_integration", "true"),
334319
resource.TestCheckResourceAttrPair("scaleway_container.main", "private_network_id", "scaleway_vpc_private_network.main", "id"),
335-
acctest.CheckResourceIDChanged("scaleway_container_namespace.main", &namespaceID),
320+
acctest.CheckResourceIDPersisted("scaleway_container_namespace.main", &namespaceID),
336321
),
337322
},
338323
},

internal/services/container/testdata/namespace-vpc-integration.cassette.yaml

Lines changed: 370 additions & 1158 deletions
Large diffs are not rendered by default.

internal/services/function/namespace.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func ResourceNamespace() *schema.Resource {
8888
},
8989
"activate_vpc_integration": {
9090
Type: schema.TypeBool,
91-
ForceNew: true,
91+
Deprecated: "VPC integration is now available on all namespaces, so this field is not configurable anymore and its value will always be \"true\".",
9292
Optional: true,
93-
Default: false,
93+
Default: true,
9494
Description: "Activate VPC integration for the namespace",
9595
},
9696
"region": regional.Schema(),
@@ -120,10 +120,6 @@ func ResourceFunctionNamespaceCreate(ctx context.Context, d *schema.ResourceData
120120
createReq.Tags = types.ExpandStrings(rawTag)
121121
}
122122

123-
if activateVPC, ok := d.GetOk("activate_vpc_integration"); ok {
124-
createReq.ActivateVpcIntegration = activateVPC.(bool)
125-
}
126-
127123
ns, err := api.CreateNamespace(createReq, scw.WithContext(ctx))
128124
if err != nil {
129125
return diag.FromErr(err)

internal/services/function/namespace_test.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package function_test
22

33
import (
44
"fmt"
5-
"regexp"
65
"testing"
76

87
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -212,27 +211,10 @@ func TestAccFunctionNamespace_VPCIntegration(t *testing.T) {
212211
`,
213212
Check: resource.ComposeTestCheckFunc(
214213
testAccCheckFunctionNamespaceExists(tt, "scaleway_function_namespace.main"),
215-
resource.TestCheckResourceAttr("scaleway_function_namespace.main", "activate_vpc_integration", "false"),
214+
resource.TestCheckResourceAttr("scaleway_function_namespace.main", "activate_vpc_integration", "true"),
216215
acctest.CheckResourceIDPersisted("scaleway_function_namespace.main", &namespaceID),
217216
),
218217
},
219-
{
220-
Config: `
221-
resource scaleway_vpc_private_network main {}
222-
223-
resource scaleway_function_namespace main {}
224-
225-
resource scaleway_function main {
226-
namespace_id = scaleway_function_namespace.main.id
227-
privacy = "private"
228-
sandbox = "v1"
229-
runtime = "go123"
230-
handler = "Handle"
231-
private_network_id = scaleway_vpc_private_network.main.id
232-
}
233-
`,
234-
ExpectError: regexp.MustCompile("Application can't be attached to private network, vpc integration must be activated on its parent namespace"),
235-
},
236218
{
237219
Config: `
238220
resource scaleway_vpc_private_network main {}
@@ -255,7 +237,7 @@ func TestAccFunctionNamespace_VPCIntegration(t *testing.T) {
255237
testAccCheckFunctionExists(tt, "scaleway_function.main"),
256238
resource.TestCheckResourceAttr("scaleway_function_namespace.main", "activate_vpc_integration", "true"),
257239
resource.TestCheckResourceAttrPair("scaleway_function.main", "private_network_id", "scaleway_vpc_private_network.main", "id"),
258-
acctest.CheckResourceIDChanged("scaleway_function_namespace.main", &namespaceID),
240+
acctest.CheckResourceIDPersisted("scaleway_function_namespace.main", &namespaceID),
259241
),
260242
},
261243
},

0 commit comments

Comments
 (0)