diff --git a/docs/data-sources/lblistener.md b/docs/data-sources/lblistener.md index 1cf0c2f..7b6f3bc 100644 --- a/docs/data-sources/lblistener.md +++ b/docs/data-sources/lblistener.md @@ -46,11 +46,15 @@ output "view" { ### Optional +- `connection_limit` (Number) - `loadbalancer_id` (String) - `project_id` (Number) - `project_name` (String) - `region_id` (Number) - `region_name` (String) +- `timeout_client_data` (Number) +- `timeout_member_connect` (Number) +- `timeout_member_data` (Number) ### Read-Only diff --git a/docs/resources/lblistener.md b/docs/resources/lblistener.md index 5682264..c4cc563 100644 --- a/docs/resources/lblistener.md +++ b/docs/resources/lblistener.md @@ -46,6 +46,7 @@ resource "gcore_lblistener" "listener" { ### Optional +- `connection_limit` (Number) - `insert_x_forwarded` (Boolean) Insert *-forwarded headers - `last_updated` (String) - `project_id` (Number) @@ -54,6 +55,9 @@ resource "gcore_lblistener" "listener" { - `region_name` (String) - `secret_id` (String) - `sni_secret_id` (List of String) +- `timeout_client_data` (Number) +- `timeout_member_connect` (Number) +- `timeout_member_data` (Number) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) ### Read-Only diff --git a/gcore/data_source_gcore_lblistener.go b/gcore/data_source_gcore_lblistener.go index aa53e8d..f6ea21d 100644 --- a/gcore/data_source_gcore_lblistener.go +++ b/gcore/data_source_gcore_lblistener.go @@ -77,6 +77,22 @@ func dataSourceLBListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "timeout_client_data": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "timeout_member_connect": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "timeout_member_data": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "connection_limit": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, }, } } @@ -128,6 +144,10 @@ func dataSourceLBListenerRead(ctx context.Context, d *schema.ResourceData, m int d.Set("loadbalancer_id", lbID) d.Set("project_id", d.Get("project_id").(int)) d.Set("region_id", d.Get("region_id").(int)) + d.Set("timeout_client_data", lb.TimeoutClientData) + d.Set("timeout_member_connect", lb.TimeoutMemberConnect) + d.Set("timeout_member_data", lb.TimeoutMemberData) + d.Set("connection_limit", lb.ConnectionLimit) log.Println("[DEBUG] Finish LBListener reading") return diags diff --git a/gcore/resource_gcore_lblistener.go b/gcore/resource_gcore_lblistener.go index acd8435..d806851 100644 --- a/gcore/resource_gcore_lblistener.go +++ b/gcore/resource_gcore_lblistener.go @@ -146,6 +146,22 @@ func resourceLbListener() *schema.Resource { Optional: true, Computed: true, }, + "timeout_client_data": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "timeout_member_connect": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "timeout_member_data": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, + "connection_limit": &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + }, }, } } @@ -169,6 +185,23 @@ func resourceLBListenerCreate(ctx context.Context, d *schema.ResourceData, m int InsertXForwarded: d.Get("insert_x_forwarded").(bool), SecretID: d.Get("secret_id").(string), } + if tcd, ok := d.GetOkExists("timeout_client_data"); ok { + timeoutClientData := tcd.(int) + opts.TimeoutClientData = &timeoutClientData + } + if tmc, ok := d.GetOkExists("timeout_member_connect"); ok { + timeoutMemberConnect := tmc.(int) + opts.TimeoutMemberConnect = &timeoutMemberConnect + } + if tmd, ok := d.GetOkExists("timeout_member_data"); ok { + timeoutMemberConnect := tmd.(int) + opts.TimeoutMemberData = &timeoutMemberConnect + } + if cl, ok := d.GetOkExists("connection_limit"); ok { + connectionLimit := cl.(int) + opts.ConnectionLimit = &connectionLimit + } + sniSecretIDRaw := d.Get("sni_secret_id").([]interface{}) if len(sniSecretIDRaw) != 0 { sniSecretID := make([]string, len(sniSecretIDRaw)) @@ -243,7 +276,7 @@ func resourceLBListenerUpdate(ctx context.Context, d *schema.ResourceData, m int config := m.(*Config) provider := config.Provider - client, err := CreateClient(provider, d, LBListenersPoint, versionPointV1) + client, err := CreateClient(provider, d, LBListenersPoint, versionPointV2) if err != nil { return diag.FromErr(err) } @@ -269,6 +302,29 @@ func resourceLBListenerUpdate(ctx context.Context, d *schema.ResourceData, m int opts.SNISecretID = sniSecretID changed = true } + if d.HasChange("timeout_client_data") { + timeoutClientData := d.Get("timeout_client_data").(int) + opts.TimeoutClientData = &timeoutClientData + changed = true + } + + if d.HasChange("timeout_member_connect") { + timeoutMemberConnect := d.Get("timeout_member_connect").(int) + opts.TimeoutMemberConnect = &timeoutMemberConnect + changed = true + } + + if d.HasChange("timeout_member_data") { + timeoutMemberData := d.Get("timeout_member_data").(int) + opts.TimeoutMemberData = &timeoutMemberData + changed = true + } + + if d.HasChange("connection_limit") { + connectionLimit := d.Get("connection_limit").(int) + opts.ConnectionLimit = &connectionLimit + changed = true + } if changed { _, err = listeners.Update(client, d.Id(), opts).Extract() diff --git a/go.mod b/go.mod index 9781c4c..f2ef467 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20230801110428-99ef24b50d4d github.com/G-Core/gcore-storage-sdk-go v0.1.34 github.com/G-Core/gcorelabscdn-go v1.0.3 - github.com/G-Core/gcorelabscloud-go v0.6.28 + github.com/G-Core/gcorelabscloud-go v0.6.30 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 github.com/mitchellh/mapstructure v1.5.0 diff --git a/go.sum b/go.sum index f1b1ae1..3c597ef 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,8 @@ github.com/G-Core/gcorelabscdn-go v1.0.1 h1:BsGnLIiH7nhvSwDLgnsaXIPIJZG6hpTsqeYP github.com/G-Core/gcorelabscdn-go v1.0.1/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE= github.com/G-Core/gcorelabscdn-go v1.0.3 h1:fBIhDNLqfKVQV7ycqhgNeyg4Pzn5LIl5yah556lAlj4= github.com/G-Core/gcorelabscdn-go v1.0.3/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE= -github.com/G-Core/gcorelabscloud-go v0.6.28 h1:o6rdeRNUr/k8ggJuMU/Fm7ZkO2k01TSdtXsjQtJqJZQ= -github.com/G-Core/gcorelabscloud-go v0.6.28/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo= +github.com/G-Core/gcorelabscloud-go v0.6.30 h1:v1fi5f5Tcr8FpsoP60j6beV0kcv84+mVH4vQopPu2oc= +github.com/G-Core/gcorelabscloud-go v0.6.30/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=