Skip to content

Commit b2552e7

Browse files
committed
feat(lb): add support for enable_access_logs
1 parent 56d47ea commit b2552e7

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

docs/resources/lb_frontend.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ The following arguments are supported:
173173

174174
- `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.
175175

176+
- `enable_access_logs` - (Default: `false`) Defines whether to enable access logs on the frontend.
177+
176178
- `acl` - (Optional) A list of ACL rules to apply to the Load Balancer frontend. Defined below.
177179

178180
## acl

internal/services/lb/data_source_lb_frontends.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ func DataSourceFrontends() *schema.Resource {
7474
Computed: true,
7575
Type: schema.TypeBool,
7676
},
77+
"connection_rate_limit": {
78+
Computed: true,
79+
Type: schema.TypeInt,
80+
},
81+
"enable_access_logs": {
82+
Computed: true,
83+
Type: schema.TypeBool,
84+
},
7785
},
7886
},
7987
},
@@ -117,6 +125,8 @@ func DataSourceLbFrontendsRead(ctx context.Context, d *schema.ResourceData, m an
117125
rawFrontend["backend_id"] = frontend.Backend.ID
118126
rawFrontend["timeout_client"] = types.FlattenDuration(frontend.TimeoutClient)
119127
rawFrontend["enable_http3"] = frontend.EnableHTTP3
128+
rawFrontend["connection_rate_limit"] = types.FlattenUint32Ptr(frontend.ConnectionRateLimit)
129+
rawFrontend["enable_access_logs"] = frontend.EnableAccessLogs
120130

121131
if len(frontend.CertificateIDs) > 0 {
122132
rawFrontend["certificate_ids"] = frontend.CertificateIDs

internal/services/lb/frontend.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ func ResourceFrontend() *schema.Resource {
228228
Optional: true,
229229
Description: "Rate limit for new connections established on this frontend. Use 0 value to disable, else value is connections per second",
230230
},
231+
"enable_access_logs": {
232+
Type: schema.TypeBool,
233+
Description: "Defines whether to enable access logs on the frontend",
234+
Optional: true,
235+
Default: false,
236+
},
231237
},
232238
}
233239
}
@@ -283,6 +289,7 @@ func resourceLbFrontendCreate(ctx context.Context, d *schema.ResourceData, m any
283289
TimeoutClient: timeoutClient,
284290
EnableHTTP3: d.Get("enable_http3").(bool),
285291
ConnectionRateLimit: types.ExpandUint32Ptr(d.Get("connection_rate_limit")),
292+
EnableAccessLogs: d.Get("enable_access_logs").(bool),
286293
}
287294

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

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

500509
_, err = lbAPI.UpdateFrontend(req, scw.WithContext(ctx))

internal/services/lb/frontend_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TestAccFrontend_Basic(t *testing.T) {
4343
lb_id = scaleway_lb.lb01.id
4444
backend_id = scaleway_lb_backend.bkd01.id
4545
inbound_port = 80
46+
enable_access_logs = true
4647
}
4748
`,
4849
Check: resource.ComposeTestCheckFunc(
@@ -51,6 +52,7 @@ func TestAccFrontend_Basic(t *testing.T) {
5152
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "timeout_client", ""),
5253
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_http3", "false"),
5354
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "connection_rate_limit", "0"),
55+
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_access_logs", "true"),
5456
),
5557
},
5658
{
@@ -75,6 +77,7 @@ func TestAccFrontend_Basic(t *testing.T) {
7577
timeout_client = "30s"
7678
enable_http3 = true
7779
connection_rate_limit = 100
80+
enable_access_logs = true
7881
}
7982
`,
8083
Check: resource.ComposeTestCheckFunc(
@@ -84,6 +87,7 @@ func TestAccFrontend_Basic(t *testing.T) {
8487
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "timeout_client", "30s"),
8588
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_http3", "true"),
8689
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "connection_rate_limit", "100"),
90+
resource.TestCheckResourceAttr("scaleway_lb_frontend.frt01", "enable_access_logs", "true"),
8791
),
8892
},
8993
},

0 commit comments

Comments
 (0)