Skip to content

Commit f3fb809

Browse files
committed
feat(instance): add support for smtp enabling
1 parent 5175d20 commit f3fb809

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

docs/resources/instance_security_group.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ The following arguments are supported:
120120

121121
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the security group is associated with.
122122

123+
- `enable_smtp` - (Optional) Enable SMTP on IPv4/IPv6 (Port 25, 465, 587).
123124

124125
The `inbound_rule` and `outbound_rule` block supports:
125126

scaleway/resource_instance_security_group.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func resourceScalewayInstanceSecurityGroup() *schema.Resource {
8080
Default: false,
8181
ConflictsWith: []string{"inbound_rule", "outbound_rule"},
8282
},
83+
"enable_smtp": {
84+
Type: schema.TypeBool,
85+
Optional: true,
86+
Default: false,
87+
},
8388
"zone": zoneSchema(),
8489
"organization_id": organizationIDSchema(),
8590
"project_id": projectIDSchema(),

scaleway/resource_instance_security_group_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,36 @@ func testSweepComputeInstanceSecurityGroup(_ string) error {
538538
return nil
539539
})
540540
}
541+
542+
func TestAccScalewayInstanceSecurityGroup_EnableSMTP(t *testing.T) {
543+
tt := NewTestTools(t)
544+
defer tt.Cleanup()
545+
resource.Test(t, resource.TestCase{
546+
PreCheck: func() { testAccPreCheck(t) },
547+
ProviderFactories: tt.ProviderFactories,
548+
CheckDestroy: testAccCheckScalewayInstanceSecurityGroupDestroy(tt),
549+
Steps: []resource.TestStep{
550+
{
551+
Config: `
552+
resource "scaleway_instance_security_group" "base" {
553+
enable_smtp = true
554+
}
555+
`,
556+
Check: resource.ComposeTestCheckFunc(
557+
resource.TestCheckResourceAttr("scaleway_instance_security_group.base", "inbound_rule.0.action", "accept"),
558+
resource.TestCheckResourceAttr("scaleway_instance_security_group.base", "inbound_rule.0.protocol", "TCP"),
559+
resource.TestCheckResourceAttr("scaleway_instance_security_group.base", "inbound_rule.0.port", "80"),
560+
resource.TestCheckResourceAttr("scaleway_instance_security_group.base", "inbound_rule.0.ip_range", "0.0.0.0/0"),
561+
testAccCheckScalewayInstanceSecurityGroupRuleMatch(tt, "scaleway_instance_security_group.base", 0, &instance.SecurityGroupRule{
562+
Direction: instance.SecurityGroupRuleDirectionInbound,
563+
IPRange: expandIPNet("0.0.0.0/0"),
564+
DestPortFrom: scw.Uint32Ptr(80),
565+
DestPortTo: nil,
566+
Protocol: instance.SecurityGroupRuleProtocolTCP,
567+
Action: instance.SecurityGroupRuleActionAccept,
568+
}),
569+
),
570+
},
571+
},
572+
})
573+
}

0 commit comments

Comments
 (0)