diff --git a/docs/resources/cdn_origingroup.md b/docs/resources/cdn_origingroup.md index 3b68e10e..12c49ed6 100644 --- a/docs/resources/cdn_origingroup.md +++ b/docs/resources/cdn_origingroup.md @@ -29,6 +29,7 @@ resource "edgecenter_cdn_origingroup" "origin_group_1" { enabled = true backup = true } + consistent_balancing = true } ``` @@ -37,6 +38,7 @@ resource "edgecenter_cdn_origingroup" "origin_group_1" { ### Required +- `consistent_balancing` (Boolean) Consistent load balancing (consistent hashing) for the source group - `name` (String) Add the source group name. - `origin` (Block Set, Min: 1) Add information about your sources. (see [below for nested schema](#nestedblock--origin)) - `use_next` (Boolean) Specify whether or not the CDN will use the next source in the list if your source responds with an HTTP status code of 4XX or 5XX. diff --git a/edgecenter/resource_edgecenter_cdn_origin_group.go b/edgecenter/resource_edgecenter_cdn_origin_group.go index c8fe0a08..b573843b 100644 --- a/edgecenter/resource_edgecenter_cdn_origin_group.go +++ b/edgecenter/resource_edgecenter_cdn_origin_group.go @@ -61,6 +61,11 @@ func resourceCDNOriginGroup() *schema.Resource { }, }, }, + "consistent_balancing": { + Type: schema.TypeBool, + Required: true, + Description: "Consistent load balancing (consistent hashing) for the source group", + }, }, CreateContext: resourceCDNOriginGroupCreate, ReadContext: resourceCDNOriginGroupRead, @@ -79,6 +84,7 @@ func resourceCDNOriginGroupCreate(ctx context.Context, d *schema.ResourceData, m req.Name = d.Get("name").(string) req.UseNext = d.Get("use_next").(bool) req.Origins = setToOriginRequests(d.Get("origin").(*schema.Set)) + req.ConsistentBalancing = d.Get("consistent_balancing").(bool) result, err := client.OriginGroups().Create(ctx, &req) if err != nil { diff --git a/edgecenter/test/resource_edgecenter_cdn_origin_group_test.go b/edgecenter/test/resource_edgecenter_cdn_origin_group_test.go index fe473ed2..de587ac8 100644 --- a/edgecenter/test/resource_edgecenter_cdn_origin_group_test.go +++ b/edgecenter/test/resource_edgecenter_cdn_origin_group_test.go @@ -38,6 +38,7 @@ func TestAccOriginGroup(t *testing.T) { source = "yandex.ru" enabled = true } + consistent_balancing = true } `, params.Source, params.Enabled) } diff --git a/examples/resources/edgecenter_cdn_origingroup/resource.tf b/examples/resources/edgecenter_cdn_origingroup/resource.tf index a111ff16..1f3216d4 100644 --- a/examples/resources/edgecenter_cdn_origingroup/resource.tf +++ b/examples/resources/edgecenter_cdn_origingroup/resource.tf @@ -14,4 +14,5 @@ resource "edgecenter_cdn_origingroup" "origin_group_1" { enabled = true backup = true } + consistent_balancing = true } diff --git a/go.mod b/go.mod index cc53fde0..06a15bcb 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AlekSi/pointer v1.2.0 github.com/Edge-Center/edgecenter-dns-sdk-go v0.1.3 github.com/Edge-Center/edgecenter-storage-sdk-go v0.2.0 - github.com/Edge-Center/edgecentercdn-go v0.1.8 + github.com/Edge-Center/edgecentercdn-go v0.1.10 github.com/Edge-Center/edgecentercloud-go v0.1.11 github.com/Edge-Center/edgecentercloud-go/v2 v2.1.4-0.20240703075841-dfdec037dd37 github.com/connerdouglass/go-retry v1.0.1 diff --git a/go.sum b/go.sum index 0aa6f97a..675dae24 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/Edge-Center/edgecenter-dns-sdk-go v0.1.3 h1:k36RWZ+dteXLMiEsu/KiSFSaN github.com/Edge-Center/edgecenter-dns-sdk-go v0.1.3/go.mod h1:xWN2LYVokamADMRz1cPhOrYX/NlxiDJp9tjBumHU5G8= github.com/Edge-Center/edgecenter-storage-sdk-go v0.2.0 h1:1aPDpywWbaF7VEjP/GjVoSgcipxWTTzEPPZv5kOWE8A= github.com/Edge-Center/edgecenter-storage-sdk-go v0.2.0/go.mod h1:TcWO0BPvDsE6AGlPBqpKCZhoQ70rRlqmm85J32qcL8I= -github.com/Edge-Center/edgecentercdn-go v0.1.8 h1:ImGcpQ/jSY3D5aSWzEca2+YgDV/Gd7jWQJbKnphBV8I= -github.com/Edge-Center/edgecentercdn-go v0.1.8/go.mod h1:RwEyxwPAmxor1mZKUTa2bIU2p5qM6kcAofUkaE4O1V4= +github.com/Edge-Center/edgecentercdn-go v0.1.10 h1:Hj+SjvPClhOYtpmoS2g33WrxyHitUBHroNSwRBZ9P1U= +github.com/Edge-Center/edgecentercdn-go v0.1.10/go.mod h1:RwEyxwPAmxor1mZKUTa2bIU2p5qM6kcAofUkaE4O1V4= github.com/Edge-Center/edgecentercloud-go v0.1.11 h1:00h5o/71lEoSdU1B4AWmviuOfO28P6nsRP+afjIsW80= github.com/Edge-Center/edgecentercloud-go v0.1.11/go.mod h1:kmXGtx0lL1ib+SPfJe/uIAyDHamquAvqiftoLSyhxF8= github.com/Edge-Center/edgecentercloud-go/v2 v2.1.4-0.20240703075841-dfdec037dd37 h1:Q2qKSUaKOxXr9s5ACVC5/zcQMjjFBTX/NUwoTQS/4m8=