Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion docs/data-sources/lb_frontends.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ In addition to all arguments above, the following attributes are exported:
~> **Important:** LB frontend IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
- `inbound_port` - TCP port the frontend listens to.
- `created_at` - The date on which the frontend was created (RFC 3339 format).
- `update_at` - The date aont which the frontend was last updated (RFC 3339 format).
- `update_at` - The date on which the frontend was last updated (RFC 3339 format).
- `backend_id` - The Load Balancer backend ID this frontend is attached to.
~> **Important:** Load Balancer backend IDs are [zoned](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
- `timeout_client` - Maximum inactivity time on the client side.
- `certificate_ids` - List of certificate IDs that are used by the frontend.
- `enable_http3` - Whether HTTP/3 protocol is activated.
- `connection_rate_limit` - The rate limit for new connections established on this frontend. Use 0 value to disable, else value is connections per second.
- `enable_access_logs` - Defines whether to enable access logs on the frontend.
5 changes: 5 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 Expand Up @@ -221,6 +223,9 @@ In addition to all arguments above, the following attributes are exported:

- `certificate_id` - (Deprecated, use `certificate_ids` instead) First certificate ID used by the frontend.

- `created_at` - The date and time the frontend was created.

- `updated_at` - The date and time the frontend resource was updated.

## Import

Expand Down
58 changes: 40 additions & 18 deletions internal/services/lb/data_source_lb_frontends.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,47 +32,67 @@ func DataSourceFrontends() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Computed: true,
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Description: "The load-balancer frontend ID",
},
"name": {
Computed: true,
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Description: "The name of the frontend",
},
"inbound_port": {
Computed: true,
Type: schema.TypeInt,
Computed: true,
Type: schema.TypeInt,
Description: "TCP port to listen on the front side",
},
"backend_id": {
Computed: true,
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Description: "The load-balancer backend ID",
},
"lb_id": {
Computed: true,
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Description: "The load-balancer ID",
},
"timeout_client": {
Computed: true,
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Description: "Set the maximum inactivity time on the client side",
},
"certificate_ids": {
Computed: true,
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "Collection of Certificate IDs related to the load balancer and domain",
},
"created_at": {
Computed: true,
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Description: "The date and time of the creation of the frontend",
},
"update_at": {
Computed: true,
Type: schema.TypeString,
Computed: true,
Type: schema.TypeString,
Description: "The date and time of the last update of the frontend",
},
"enable_http3": {
Computed: true,
Type: schema.TypeBool,
Computed: true,
Type: schema.TypeBool,
Description: "Activates HTTP/3 protocol",
},
"connection_rate_limit": {
Computed: true,
Type: schema.TypeInt,
Description: "Rate limit for new connections established on this frontend. Use 0 value to disable, else value is connections per second",
},
"enable_access_logs": {
Computed: true,
Type: schema.TypeBool,
Description: "Defines whether to enable access logs on the frontend",
},
},
},
Expand Down Expand Up @@ -117,6 +137,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
21 changes: 21 additions & 0 deletions internal/services/lb/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ 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,
},
"created_at": {
Type: schema.TypeString,
Computed: true,
Description: "The date and time of the creation of the frontend",
},
"updated_at": {
Type: schema.TypeString,
Computed: true,
Description: "The date and time of the last update of the frontend",
},
},
}
}
Expand Down Expand Up @@ -283,6 +299,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 +348,9 @@ 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)
_ = d.Set("created_at", types.FlattenTime(frontend.CreatedAt))
_ = d.Set("updated_at", types.FlattenTime(frontend.UpdatedAt))

if frontend.Certificate != nil { //nolint:staticcheck
_ = d.Set("certificate_id", zonal.NewIDString(zone, frontend.Certificate.ID)) //nolint:staticcheck
Expand Down Expand Up @@ -495,6 +515,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