@@ -38,6 +38,25 @@ func TestAccACL_Basic(t *testing.T) {
3838 resource .TestCheckResourceAttr ("scaleway_vpc_acl.acl01" , "default_policy" , "accept" ),
3939 ),
4040 },
41+ {
42+ Config : `
43+ resource "scaleway_vpc" "vpc01" {
44+ name = "tf-vpc-acl-basic"
45+ }
46+
47+ resource "scaleway_vpc_acl" "acl01" {
48+ vpc_id = scaleway_vpc.vpc01.id
49+ is_ipv6 = false
50+ default_policy = "drop"
51+ }
52+ ` ,
53+ Check : resource .ComposeTestCheckFunc (
54+ isACLPresent (tt , "scaleway_vpc_acl.acl01" ),
55+ resource .TestCheckResourceAttrPair ("scaleway_vpc_acl.acl01" , "vpc_id" , "scaleway_vpc.vpc01" , "id" ),
56+ resource .TestCheckResourceAttr ("scaleway_vpc_acl.acl01" , "is_ipv6" , "false" ),
57+ resource .TestCheckResourceAttr ("scaleway_vpc_acl.acl01" , "default_policy" , "drop" ),
58+ ),
59+ },
4160 },
4261 })
4362}
@@ -151,6 +170,16 @@ func TestAccACL_WithRules(t *testing.T) {
151170 resource .TestCheckResourceAttr ("scaleway_vpc_acl.acl01" , "rules.1.action" , "accept" ),
152171 ),
153172 },
173+ {
174+ Config : `
175+ resource "scaleway_vpc" "vpc01" {
176+ name = "tf-vpc-acl"
177+ }
178+ ` ,
179+ Check : resource .ComposeTestCheckFunc (
180+ testAccCheckACLDefaultPolicy (tt , "scaleway_vpc.vpc01" ),
181+ ),
182+ },
154183 },
155184 })
156185}
@@ -208,3 +237,32 @@ func isACLDestroyed(tt *acctest.TestTools) resource.TestCheckFunc {
208237 return nil
209238 }
210239}
240+
241+ func testAccCheckACLDefaultPolicy (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
242+ return func (s * terraform.State ) error {
243+ rs , ok := s .RootModule ().Resources [n ]
244+ if ! ok {
245+ return fmt .Errorf ("resource not found: %s" , n )
246+ }
247+
248+ vpcAPI , region , ID , err := vpc .NewAPIWithRegionAndID (tt .Meta , rs .Primary .ID )
249+ if err != nil {
250+ return err
251+ }
252+
253+ acl , err := vpcAPI .GetACL (& vpcSDK.GetACLRequest {
254+ VpcID : ID ,
255+ Region : region ,
256+ IsIPv6 : false ,
257+ })
258+ if err != nil {
259+ return err
260+ }
261+
262+ if acl .DefaultPolicy .String () != vpcSDK .ActionAccept .String () {
263+ return fmt .Errorf ("expected default_policy to be %s, got %s" , vpcSDK .ActionAccept .String (), acl .DefaultPolicy .String ())
264+ }
265+
266+ return nil
267+ }
268+ }
0 commit comments