diff --git a/docs/resources/cdn_rule.md b/docs/resources/cdn_rule.md index ab07bd4..22ad15a 100644 --- a/docs/resources/cdn_rule.md +++ b/docs/resources/cdn_rule.md @@ -130,9 +130,10 @@ resource "gcore_cdn_resource" "cdn_example_com" { ### Optional +- `active` (Boolean) The setting allows to enable or disable a Rule. If not specified, it will be enabled. - `options` (Block List, Max: 1) Each option in CDN resource settings. Each option added to CDN resource settings should have the following mandatory request fields: enabled, value. (see [below for nested schema](#nestedblock--options)) - `origin_group` (Number) ID of the Origins Group. Use one of your Origins Group or create a new one. You can use either 'origin' parameter or 'originGroup' in the resource definition. -- `origin_protocol` (String) This option defines the protocol that will be used by CDN servers to request content from an origin source. If not specified, it will be inherit from resource. Possible values are: HTTPS, HTTP, MATCH. +- `origin_protocol` (String) This option defines the protocol that will be used by CDN servers to request content from an origin source. If not specified, it will be inherited from resource. Possible values are: HTTPS, HTTP, MATCH. - `weight` (Number) Rule weight that determines rule execution order: from the smallest (0) to the highest. ### Read-Only diff --git a/gcore/resource_gcore_cdn_rule.go b/gcore/resource_gcore_cdn_rule.go index 46ac213..c066bab 100644 --- a/gcore/resource_gcore_cdn_rule.go +++ b/gcore/resource_gcore_cdn_rule.go @@ -53,6 +53,12 @@ func resourceCDNRule() *schema.Resource { Required: true, Description: "Rule name", }, + "active": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "The setting allows to enable or disable a Rule. If not specified, it will be enabled.", + }, "rule": { Type: schema.TypeString, Required: true, @@ -97,6 +103,7 @@ func resourceCDNRuleCreate(ctx context.Context, d *schema.ResourceData, m interf var req rules.CreateRequest req.Name = d.Get("name").(string) + req.Active = d.Get("active").(bool) req.Rule = d.Get("rule").(string) req.RuleType = d.Get("rule_type").(int) @@ -147,6 +154,7 @@ func resourceCDNRuleRead(ctx context.Context, d *schema.ResourceData, m interfac } d.Set("name", result.Name) + d.Set("active", result.Active) d.Set("rule", result.Pattern) d.Set("rule_type", result.Type) d.Set("origin_group", result.OriginGroup) @@ -173,6 +181,7 @@ func resourceCDNRuleUpdate(ctx context.Context, d *schema.ResourceData, m interf var req rules.UpdateRequest req.Name = d.Get("name").(string) + req.Active = d.Get("active").(bool) req.Rule = d.Get("rule").(string) req.RuleType = d.Get("rule_type").(int) diff --git a/go.mod b/go.mod index bf94bc0..1a4c10d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AlekSi/pointer v1.2.0 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.1 + github.com/G-Core/gcorelabscdn-go v1.0.2 github.com/G-Core/gcorelabscloud-go v0.6.15 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 diff --git a/go.sum b/go.sum index f7b72da..a3f9946 100644 --- a/go.sum +++ b/go.sum @@ -9,6 +9,8 @@ github.com/G-Core/gcorelabscdn-go v1.0.0 h1:aPjwy6UWAmi8p+Vi8OEfmDM4bOq5r+rkOi9S github.com/G-Core/gcorelabscdn-go v1.0.0/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE= github.com/G-Core/gcorelabscdn-go v1.0.1 h1:BsGnLIiH7nhvSwDLgnsaXIPIJZG6hpTsqeYPr+W6/qM= github.com/G-Core/gcorelabscdn-go v1.0.1/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE= +github.com/G-Core/gcorelabscdn-go v1.0.2 h1:PLUUGal7GftuQxP+VyEwMYZ47e4S/jvYZKRnDezcpMY= +github.com/G-Core/gcorelabscdn-go v1.0.2/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE= github.com/G-Core/gcorelabscloud-go v0.6.2 h1:oCo3yurVnGKZLkRuQ7GVQK1LuLFEjq3mFWiX/PUI69M= github.com/G-Core/gcorelabscloud-go v0.6.2/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo= github.com/G-Core/gcorelabscloud-go v0.6.15 h1:lyzUPvQy7/KM0n4ErKpM4BpJA0iKrv82pHAimWfxNwA=