diff --git a/incapsula/client_application_delivery.go b/incapsula/client_application_delivery.go index 25450108..9263ea15 100644 --- a/incapsula/client_application_delivery.go +++ b/incapsula/client_application_delivery.go @@ -10,13 +10,15 @@ import ( ) type Compression struct { - FileCompression bool `json:"file_compression"` - MinifyJs bool `json:"minify_js"` - MinifyCss bool `json:"minify_css"` - MinifyStaticHtml bool `json:"minify_static_html"` + FileCompression bool `json:"file_compression"` + CompressionType string `json:"compression_type"` + MinifyJs bool `json:"minify_js"` + MinifyCss bool `json:"minify_css"` + MinifyStaticHtml bool `json:"minify_static_html"` } type CompressionStr struct { FileCompression string `json:"file_compression"` + CompressionType string `json:"compression_type"` MinifyJs string `json:"minify_js"` MinifyCss string `json:"minify_css"` MinifyStaticHtml string `json:"minify_static_html"` diff --git a/incapsula/client_application_delivery_test.go b/incapsula/client_application_delivery_test.go index 31cc848e..711fdcfc 100644 --- a/incapsula/client_application_delivery_test.go +++ b/incapsula/client_application_delivery_test.go @@ -144,6 +144,7 @@ func TestUpdateApplicationDeliveryConfig(t *testing.T) { { "compression": { "file_compression": true, + "compression_type": "GZIP", "minify_js": true, "minify_css": false, "minify_static_html": true @@ -315,6 +316,7 @@ func TestReadApplicationDeliveryConfig(t *testing.T) { { "compression": { "file_compression": true, + "compression_type": "GZIP", "minify_js": true, "minify_css": false, "minify_static_html": true diff --git a/incapsula/resource_application_delivery.go b/incapsula/resource_application_delivery.go index da5ff440..33166a1f 100644 --- a/incapsula/resource_application_delivery.go +++ b/incapsula/resource_application_delivery.go @@ -2,10 +2,12 @@ package incapsula import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "log" "strconv" "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) const defaultPortTo = 80 @@ -42,10 +44,17 @@ func resourceApplicationDelivery() *schema.Resource { // Optional Arguments "file_compression": { Type: schema.TypeBool, - Description: "When this option is enabled, any textual resource, such as Javascript, CSS and HTML, is compressed using Gzip as it is being transferred, and then unzipped within the browser. All modern browsers support this feature.", + Description: "When this option is enabled, files such as JavaScript, CSS and HTML are dynamically compressed using the selected format as they are transferred. They are automatically unzipped within the browser. If Brotli is not supported by the browser, files are automatically sent in Gzip.", Optional: true, Default: true, }, + "compression_type": { + Type: schema.TypeString, + Description: "Gzip (default). Brotli (recommended for more efficient compression)", + Optional: true, + Default: "GZIP", + ValidateFunc: validation.StringInSlice([]string{"GZIP", "BROTLI"}, false), + }, "minify_js": { Type: schema.TypeBool, Description: "Minify JavaScript. Minification removes characters that are not necessary for rendering the page, such as whitespace and comments. This makes the files smaller and therefore reduces their access time. Minification has no impact on the functionality of the Javascript, CSS, and HTML files.", @@ -292,6 +301,7 @@ func resourceApplicationDeliveryRead(d *schema.ResourceData, m interface{}) erro d.SetId(siteIdStr) d.Set("file_compression", applicationDelivery.Compression.FileCompression) + d.Set("compression_type", applicationDelivery.Compression.CompressionType) d.Set("minify_js", applicationDelivery.Compression.MinifyJs) d.Set("minify_css", applicationDelivery.Compression.MinifyCss) d.Set("minify_static_html", applicationDelivery.Compression.MinifyStaticHtml) @@ -331,6 +341,7 @@ func resourceApplicationDeliveryUpdate(d *schema.ResourceData, m interface{}) er compression := Compression{ FileCompression: d.Get("file_compression").(bool), + CompressionType: d.Get("compression_type").(string), MinifyJs: d.Get("minify_js").(bool), MinifyCss: d.Get("minify_css").(bool), MinifyStaticHtml: d.Get("minify_static_html").(bool), diff --git a/incapsula/resource_application_delivery_test.go b/incapsula/resource_application_delivery_test.go index 94e16f1c..a9f79a59 100644 --- a/incapsula/resource_application_delivery_test.go +++ b/incapsula/resource_application_delivery_test.go @@ -28,6 +28,7 @@ func TestAccIncapsulaApplicationDelivery_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckApplicationDeliveryExists(applicationDeliveryResource), resource.TestCheckResourceAttr(applicationDeliveryResource, "file_compression", "true"), + resource.TestCheckResourceAttr(applicationDeliveryResource, "compression_type", "GZIP"), resource.TestCheckResourceAttr(applicationDeliveryResource, "minify_css", "true"), //value wasn't set by tf resurce. checking default value from server resource.TestCheckResourceAttr(applicationDeliveryResource, "minify_js", "true"), resource.TestCheckResourceAttr(applicationDeliveryResource, "minify_static_html", "false"), @@ -105,6 +106,7 @@ resource "%s" "%s" { site_id = incapsula_site.testacc-terraform-site.id depends_on = ["%s"] file_compression = true + compression_file = GZIP compress_jpeg = true minify_static_html = false aggressive_compression = true diff --git a/website/docs/r/application_delivery.html.markdown b/website/docs/r/application_delivery.html.markdown index e38cb003..60c0f3f3 100644 --- a/website/docs/r/application_delivery.html.markdown +++ b/website/docs/r/application_delivery.html.markdown @@ -18,6 +18,7 @@ Note that destroy action will return the configuration to the default values. resource "incapsula_application_delivery" "example_application_delivery" { site_id = incapsula_site.testacc-terraform-site.id file_compression = true + compression_type = "GZIP" minify_css = true minify_js = true minify_static_html = false @@ -46,6 +47,7 @@ The following arguments are supported: * `site_id` - (Required) Numeric identifier of the site to operate on. * `file_compression` - (Optional) Compress JPEG images. Compression reduces download time by reducing the file size. Default: true +* `compression_type` - (Optional) BROTLI (recommended for more efficient compression). Default: GZIP * `minify_js` - (Optional) Minify JavaScript. Minification removes characters that are not necessary for rendering the page, such as whitespace and comments. This makes the files smaller and therefore reduces their access time. Minification has no impact on the functionality of the Javascript, CSS, and HTML files. Default: true * `minify_css` - (Optional) Content minification can applied only to cached Javascript, CSS and HTML content. Default: true. * `minify_static_html` - (Optional) Minify static HTML. Default: true.