Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/resources/lb_frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ The following arguments are supported:

- `connection_rate_limit` - (Optional) The rate limit for new connections established on this frontend. Use 0 value to disable, else value is connections per second.

- `enable_access_logs` - (Default: `false`) Defines whether to enable access logs on the frontend.

- `acl` - (Optional) A list of ACL rules to apply to the Load Balancer frontend. Defined below.

## acl
Expand Down
10 changes: 10 additions & 0 deletions internal/services/lb/data_source_lb_frontends.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ func DataSourceFrontends() *schema.Resource {
Computed: true,
Type: schema.TypeBool,
},
"connection_rate_limit": {
Computed: true,
Type: schema.TypeInt,
},
"enable_access_logs": {
Computed: true,
Type: schema.TypeBool,
},
},
},
},
Expand Down Expand Up @@ -117,6 +125,8 @@ func DataSourceLbFrontendsRead(ctx context.Context, d *schema.ResourceData, m an
rawFrontend["backend_id"] = frontend.Backend.ID
rawFrontend["timeout_client"] = types.FlattenDuration(frontend.TimeoutClient)
rawFrontend["enable_http3"] = frontend.EnableHTTP3
rawFrontend["connection_rate_limit"] = types.FlattenUint32Ptr(frontend.ConnectionRateLimit)
rawFrontend["enable_access_logs"] = frontend.EnableAccessLogs

if len(frontend.CertificateIDs) > 0 {
rawFrontend["certificate_ids"] = frontend.CertificateIDs
Expand Down
9 changes: 9 additions & 0 deletions internal/services/lb/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ func ResourceFrontend() *schema.Resource {
Optional: true,
Description: "Rate limit for new connections established on this frontend. Use 0 value to disable, else value is connections per second",
},
"enable_access_logs": {
Type: schema.TypeBool,
Description: "Defines whether to enable access logs on the frontend",
Optional: true,
Default: false,
},
},
}
}
Expand Down Expand Up @@ -283,6 +289,7 @@ func resourceLbFrontendCreate(ctx context.Context, d *schema.ResourceData, m any
TimeoutClient: timeoutClient,
EnableHTTP3: d.Get("enable_http3").(bool),
ConnectionRateLimit: types.ExpandUint32Ptr(d.Get("connection_rate_limit")),
EnableAccessLogs: d.Get("enable_access_logs").(bool),
}

certificatesRaw, certificatesExist := d.GetOk("certificate_ids")
Expand Down Expand Up @@ -331,6 +338,7 @@ func resourceLbFrontendRead(ctx context.Context, d *schema.ResourceData, m any)
_ = d.Set("timeout_client", types.FlattenDuration(frontend.TimeoutClient))
_ = d.Set("enable_http3", frontend.EnableHTTP3)
_ = d.Set("connection_rate_limit", types.FlattenUint32Ptr(frontend.ConnectionRateLimit))
_ = d.Set("enable_access_logs", frontend.EnableAccessLogs)

if frontend.Certificate != nil { //nolint:staticcheck
_ = d.Set("certificate_id", zonal.NewIDString(zone, frontend.Certificate.ID)) //nolint:staticcheck
Expand Down Expand Up @@ -495,6 +503,7 @@ func resourceLbFrontendUpdate(ctx context.Context, d *schema.ResourceData, m any
CertificateIDs: types.ExpandSliceIDsPtr(d.Get("certificate_ids")),
EnableHTTP3: d.Get("enable_http3").(bool),
ConnectionRateLimit: types.ExpandUint32Ptr(d.Get("connection_rate_limit")),
EnableAccessLogs: types.ExpandBoolPtr(d.Get("enable_access_logs")),
}

_, err = lbAPI.UpdateFrontend(req, scw.WithContext(ctx))
Expand Down
3 changes: 3 additions & 0 deletions internal/services/lb/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestAccFrontend_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "timeout_client", ""),
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_http3", "false"),
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "connection_rate_limit", "0"),
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_access_logs", "false"),
),
},
{
Expand All @@ -75,6 +76,7 @@ func TestAccFrontend_Basic(t *testing.T) {
timeout_client = "30s"
enable_http3 = true
connection_rate_limit = 100
enable_access_logs = true
}
`,
Check: resource.ComposeTestCheckFunc(
Expand All @@ -84,6 +86,7 @@ func TestAccFrontend_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "timeout_client", "30s"),
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_http3", "true"),
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "connection_rate_limit", "100"),
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_access_logs", "true"),
),
},
},
Expand Down
Loading
Loading