Skip to content

Commit 10a3a01

Browse files
committed
feat(instance): add support for smtp enabling
1 parent 0e2330e commit 10a3a01

File tree

4 files changed

+448
-0
lines changed

4 files changed

+448
-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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ func resourceScalewayInstanceSecurityGroup() *schema.Resource {
8282
Default: false,
8383
ConflictsWith: []string{"inbound_rule", "outbound_rule"},
8484
},
85+
"enable_smtp": {
86+
Type: schema.TypeBool,
87+
Optional: true,
88+
Default: false,
89+
},
8590
"zone": zoneSchema(),
8691
"organization_id": organizationIDSchema(),
8792
"project_id": projectIDSchema(),
@@ -144,6 +149,7 @@ func resourceScalewayInstanceSecurityGroupRead(ctx context.Context, d *schema.Re
144149
_ = d.Set("description", res.SecurityGroup.Description)
145150
_ = d.Set("inbound_default_policy", res.SecurityGroup.InboundDefaultPolicy.String())
146151
_ = d.Set("outbound_default_policy", res.SecurityGroup.OutboundDefaultPolicy.String())
152+
_ = d.Set("enable_smtp", !res.SecurityGroup.EnableDefaultSecurity)
147153

148154
if !d.Get("external_rules").(bool) {
149155
inboundRules, outboundRules, err := getSecurityGroupRules(instanceAPI, zone, ID, d)

scaleway/resource_instance_security_group_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,25 @@ 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 = false
554+
}
555+
`,
556+
Check: resource.ComposeTestCheckFunc(
557+
resource.TestCheckResourceAttr("scaleway_instance_security_group.base", "enable_smtp", "false"),
558+
),
559+
},
560+
},
561+
})
562+
}

0 commit comments

Comments
 (0)