Skip to content

Commit 609e094

Browse files
committed
Merge branch 'feat/add-waf' of github.com:yfodil/terraform-provider-scaleway into feat/add-waf
2 parents 791291d + b061313 commit 609e094

12 files changed

+3632
-1180
lines changed

docs/resources/tem_domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ The following arguments are supported:
113113
~> **Important:** This attribute must be set to `true`.
114114

115115
- `region` - (Defaults to [provider](../index.md#region) `region`). The [region](../guides/regions_and_zones.md#regions) in which the domain should be created.
116+
~> **Important:** Currently, only fr-par is supported. Specifying any other region will cause an error.
116117

117118
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the domain is associated with.
118119

docs/resources/vpc_acl.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
subcategory: "VPC"
3+
page_title: "Scaleway: scaleway_vpc_acl"
4+
---
5+
6+
# Resource: scaleway_vpc_acl
7+
8+
Creates and manages Scaleway VPC ACLs.
9+
10+
## Example Usage
11+
12+
### Basic
13+
14+
```terraform
15+
resource "scaleway_vpc" "vpc01" {
16+
name = "tf-vpc-acl"
17+
}
18+
19+
resource "scaleway_vpc_acl" "acl01" {
20+
vpc_id = scaleway_vpc.vpc01.id
21+
is_ipv6 = false
22+
rules {
23+
protocol = "TCP"
24+
src_port_low = 0
25+
src_port_high = 0
26+
dst_port_low = 80
27+
dst_port_high = 80
28+
source = "0.0.0.0/0"
29+
destination = "0.0.0.0/0"
30+
description = "Allow HTTP traffic from any source"
31+
action = "accept"
32+
}
33+
default_policy = "drop"
34+
}
35+
```
36+
37+
## Argument Reference
38+
39+
The following arguments are supported:
40+
41+
- `vpc_id` - (Required) The VPC ID the ACL belongs to.
42+
- `default_policy` - (Required) The action to take for packets which do not match any rules.
43+
- `is_ipv6` - (Optional) Defines whether this set of ACL rules is for IPv6 (false = IPv4). Each Network ACL can have rules for only one IP type.
44+
- `rules` - (Optional) The list of Network ACL rules.
45+
- `protocol` - (Optional) The protocol to which this rule applies. Default value: ANY.
46+
- `source` - (Optional) The Source IP range to which this rule applies (CIDR notation with subnet mask).
47+
- `src_port_low` - (Optional) The starting port of the source port range to which this rule applies (inclusive).
48+
- `src_port_high` - (Optional) The ending port of the source port range to which this rule applies (inclusive).
49+
- `destination` - (Optional) The destination IP range to which this rule applies (CIDR notation with subnet mask).
50+
- `dst_port_low` - (Optional) The starting port of the destination port range to which this rule applies (inclusive).
51+
- `dst_port_high` - (Optional) The ending port of the destination port range to which this rule applies (inclusive).
52+
- `action` - (Optional) The policy to apply to the packet.
53+
- `description` - (Optional) The rule description.
54+
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) of the ACL.
55+
56+
## Attributes Reference
57+
58+
In addition to all arguments above, the following attributes are exported:
59+
60+
- `id` - The ID of the ACL.
61+
62+
~> **Important:** ACLs' IDs are [regional](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-111111111111
63+
64+
## Import
65+
66+
ACLs can be imported using `{region}/{id}`, e.g.
67+
68+
```bash
69+
terraform import scaleway_vpc_acl.main fr-par/11111111-1111-1111-1111-111111111111
70+
```

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ func Provider(config *Config) plugin.ProviderFunc {
228228
"scaleway_tem_domain_validation": tem.ResourceDomainValidation(),
229229
"scaleway_tem_webhook": tem.ResourceWebhook(),
230230
"scaleway_vpc": vpc.ResourceVPC(),
231+
"scaleway_vpc_acl": vpc.ResourceACL(),
231232
"scaleway_vpc_gateway_network": vpcgw.ResourceNetwork(),
232233
"scaleway_vpc_private_network": vpc.ResourcePrivateNetwork(),
233234
"scaleway_vpc_public_gateway": vpcgw.ResourcePublicGateway(),

internal/services/tem/domain_validation.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ func ResourceDomainValidationCreate(ctx context.Context, d *schema.ResourceData,
8989
return nil
9090
})
9191

92+
domainCheck, _ := api.CheckDomain(&tem.CheckDomainRequest{
93+
Region: region,
94+
DomainID: domain.ID,
95+
})
96+
if domainCheck == nil || domainCheck.Status == "pending" || domainCheck.Status == "unchecked" || domainCheck.Status == "autoconfiguring" {
97+
d.SetId("")
98+
99+
return diag.Errorf("domain validation did not complete in %d seconds", duration)
100+
}
101+
92102
return ResourceDomainValidationRead(ctx, d, meta)
93103
}
94104

internal/services/tem/domain_validation_test.go

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

33
import (
44
"fmt"
5+
"regexp"
56
"testing"
67

78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -10,11 +11,11 @@ import (
1011

1112
const domainNameValidation = "scaleway-terraform.com"
1213

13-
func TestAccDomainValidation_NoValidation(t *testing.T) {
14+
func TestAccDomainValidation_Validation(t *testing.T) {
1415
tt := acctest.NewTestTools(t)
1516
defer tt.Cleanup()
1617

17-
subDomainName := "validation-no-validation"
18+
subDomainName := "validation-validation"
1819

1920
resource.ParallelTest(t, resource.TestCase{
2021
PreCheck: func() { acctest.PreCheck(t) },
@@ -32,27 +33,28 @@ func TestAccDomainValidation_NoValidation(t *testing.T) {
3233
resource scaleway_tem_domain cr01 {
3334
name = scaleway_domain_zone.test.id
3435
accept_tos = true
36+
autoconfig = true
3537
}
3638
3739
resource scaleway_tem_domain_validation valid {
3840
domain_id = scaleway_tem_domain.cr01.id
3941
region = scaleway_tem_domain.cr01.region
40-
timeout = 1
42+
timeout = 3600
4143
}
4244
`, domainNameValidation, subDomainName),
4345
Check: resource.ComposeTestCheckFunc(
44-
resource.TestCheckResourceAttr("scaleway_tem_domain_validation.valid", "validated", "false"),
46+
resource.TestCheckResourceAttr("scaleway_tem_domain_validation.valid", "validated", "true"),
4547
),
4648
},
4749
},
4850
})
4951
}
5052

51-
func TestAccDomainValidation_Validation(t *testing.T) {
53+
func TestAccDomainValidation_TimeoutError(t *testing.T) {
5254
tt := acctest.NewTestTools(t)
5355
defer tt.Cleanup()
5456

55-
subDomainName := "validation-validation"
57+
subDomainName := "validation-timeout"
5658

5759
resource.ParallelTest(t, resource.TestCase{
5860
PreCheck: func() { acctest.PreCheck(t) },
@@ -62,26 +64,23 @@ func TestAccDomainValidation_Validation(t *testing.T) {
6264
{
6365
Config: fmt.Sprintf(`
6466
65-
resource "scaleway_domain_zone" "test" {
66-
domain = "%s"
67-
subdomain = "%s"
68-
}
67+
resource "scaleway_domain_zone" "test" {
68+
domain = "%s"
69+
subdomain = "%s"
70+
}
6971
70-
resource scaleway_tem_domain cr01 {
71-
name = scaleway_domain_zone.test.id
72-
accept_tos = true
73-
autoconfig = true
74-
}
72+
resource scaleway_tem_domain cr01 {
73+
name = scaleway_domain_zone.test.id
74+
accept_tos = true
75+
}
7576
76-
resource scaleway_tem_domain_validation valid {
77-
domain_id = scaleway_tem_domain.cr01.id
78-
region = scaleway_tem_domain.cr01.region
79-
timeout = 3600
80-
}
81-
`, domainNameValidation, subDomainName),
82-
Check: resource.ComposeTestCheckFunc(
83-
resource.TestCheckResourceAttr("scaleway_tem_domain_validation.valid", "validated", "true"),
84-
),
77+
resource scaleway_tem_domain_validation valid {
78+
domain_id = scaleway_tem_domain.cr01.id
79+
region = scaleway_tem_domain.cr01.region
80+
timeout = 1
81+
}
82+
`, domainNameValidation, subDomainName),
83+
ExpectError: regexp.MustCompile("(?i)domain validation did not complete"),
8584
},
8685
},
8786
})

0 commit comments

Comments
 (0)