-
Notifications
You must be signed in to change notification settings - Fork 56
feat(cdn): Add support for configuring WAF #1372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7c989aa
7cca33f
e850a14
cf6f255
72d079c
cafad57
f2bcc1b
a5f9f48
9addaea
618c3a2
9a22cef
83c4b94
6d30d9b
cf12967
45905c6
92dfd6f
9ccd292
56f3e9c
23d6bd9
731fb3f
162d0d8
bd94faa
312cca0
a15c7f7
d3929ad
100d9f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ data "stackit_cdn_distribution" "example" { | |
|
|
||
| ### Required | ||
|
|
||
| - `distribution_id` (String) STACKIT project ID associated with the distribution | ||
| - `distribution_id` (String) CDN distribution ID | ||
| - `project_id` (String) STACKIT project ID associated with the distribution | ||
|
|
||
| ### Read-Only | ||
|
|
@@ -51,15 +51,17 @@ Read-Only: | |
|
|
||
| - `backend` (Attributes) The configured backend for the distribution (see [below for nested schema](#nestedatt--config--backend)) | ||
| - `optimizer` (Attributes) Configuration for the Image Optimizer. This is a paid feature that automatically optimizes images to reduce their file size for faster delivery, leading to improved website performance and a better user experience. (see [below for nested schema](#nestedatt--config--optimizer)) | ||
| - `redirects` (Attributes) A wrapper for a list of redirect rules that allows for redirect settings on a distribution (see [below for nested schema](#nestedatt--config--redirects)) | ||
| - `regions` (List of String) The configured regions where content will be hosted | ||
| - `waf` (Attributes) Configuration of the Web Application Firewall (WAF) for the distribution. Removing this block from your configuration will completely disable the WAF. (see [below for nested schema](#nestedatt--config--waf)) | ||
|
|
||
| <a id="nestedatt--config--backend"></a> | ||
| ### Nested Schema for `config.backend` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `bucket_url` (String) The URL of the bucket (e.g. https://s3.example.com). Required if type is 'bucket'. | ||
| - `geofencing` (Map of List of String) The configured type http to configure countries where content is allowed. A map of URLs to a list of countries | ||
| - `geofencing` (Map of List of String) Routes users from specific countries to alternative origins (HTTP backend required). Configure this by mapping the alternative origin URL to a list of country codes | ||
| - `origin_request_headers` (Map of String) The configured type http origin request headers for the backend | ||
| - `origin_url` (String) The configured backend type http for the distribution | ||
| - `region` (String) The region where the bucket is hosted. Required if type is 'bucket'. | ||
|
|
@@ -74,6 +76,58 @@ Read-Only: | |
| - `enabled` (Boolean) | ||
|
|
||
|
|
||
| <a id="nestedatt--config--redirects"></a> | ||
| ### Nested Schema for `config.redirects` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `rules` (Attributes List) A list of redirect rules. The order of rules matters for evaluation (see [below for nested schema](#nestedatt--config--redirects--rules)) | ||
|
|
||
| <a id="nestedatt--config--redirects--rules"></a> | ||
| ### Nested Schema for `config.redirects.rules` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `description` (String) An optional description for the redirect rule | ||
| - `enabled` (Boolean) A toggle to enable or disable the redirect rule. Default to true | ||
| - `matchers` (Attributes List) A list of matchers that define when this rule should apply. At least one matcher is required (see [below for nested schema](#nestedatt--config--redirects--rules--matchers)) | ||
| - `rule_match_condition` (String) Defines how multiple matchers within this rule are combined (ALL, ANY, NONE). Defaults to ANY. | ||
| - `status_code` (Number) The HTTP status code for the redirect. Must be one of 301, 302, 303, 307, or 308. | ||
| - `target_url` (String) The target URL to redirect to. Must be a valid URI | ||
|
|
||
| <a id="nestedatt--config--redirects--rules--matchers"></a> | ||
| ### Nested Schema for `config.redirects.rules.matchers` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `value_match_condition` (String) Defines how multiple matchers within this rule are combined (ALL, ANY, NONE). Defaults to ANY. | ||
| - `values` (List of String) A list of glob patterns to match against the request path. At least one value is required. Examples: "/shop/*" or "*/img/*" | ||
|
|
||
|
|
||
|
|
||
|
|
||
| <a id="nestedatt--config--waf"></a> | ||
| ### Nested Schema for `config.waf` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `allowed_http_methods` (List of String) Restricts which HTTP methods the distribution accepts. If provided, the list must contain at least one item. If omitted, the API applies the following defaults: `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH`. | ||
| - `allowed_http_versions` (List of String) Restricts which HTTP protocol versions are accepted. If provided, the list must contain at least one item. If omitted, the API applies the following defaults: `HTTP/1.0`, `HTTP/1.1`, `HTTP/2`, `HTTP/2.0`. | ||
| - `allowed_request_content_types` (List of String) Restricts which Content-Type headers are accepted in request bodies. If provided, the list must contain at least one item. If omitted, the API applies the following defaults: `application/x-www-form-urlencoded`, `multipart/form-data`, `multipart/related`, `text/xml`, `application/xml`, `application/soap+xml`, `application/x-amf`, `application/json`, `application/octet-stream`, `application/csp-report`, `application/xss-auditor-report`, `text/plain`. | ||
| - `disabled_rule_collection_ids` (List of String) List of WAF Collection IDs explicitly disabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule collections, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `disabled_rule_group_ids` (List of String) List of WAF Rule Group IDs explicitly disabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule groups, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sentence "Precendence hierarchy" is written for almost every attribute and is almost the same. Does it make sense to have this for every attribute or should this just be mentioned somewhere "globally"? |
||
| - `disabled_rule_ids` (List of String) List of WAF rule IDs explicitly disabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. For example, an explicitly disabled Rule ID takes precedence over an enabled Group ID. To view available rules, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `enabled_rule_collection_ids` (List of String) List of WAF Collection IDs explicitly enabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule collections, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `enabled_rule_group_ids` (List of String) List of WAF Rule Group IDs explicitly enabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule groups, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `enabled_rule_ids` (List of String) List of WAF rule IDs explicitly enabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. For example, an explicitly enabled Rule ID takes precedence over a disabled Group ID. To view available rules, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `log_only_rule_collection_ids` (List of String) List of WAF Collection IDs explicitly marked as Log Only. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule collections, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `log_only_rule_group_ids` (List of String) List of WAF Rule Group IDs explicitly marked as Log Only. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule groups, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `log_only_rule_ids` (List of String) List of WAF rule IDs explicitly marked as Log Only. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rules, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `mode` (String) The operating mode of the WAF. 'ENABLED' actively blocks threats, 'LOG_ONLY' logs matches without blocking, and 'DISABLED' completely turns off inspection. Defaults to 'DISABLED'. | ||
| - `paranoia_level` (String) Defines how aggressively the WAF should act on requests. Valid values are 'L1' to 'L4'. Defaults to 'L1'. | ||
| - `type` (String) The tier of the WAF. Valid values are 'FREE' or 'PREMIUM'. Defaults to 'FREE'. | ||
|
|
||
|
|
||
|
|
||
| <a id="nestedatt--domains"></a> | ||
| ### Nested Schema for `domains` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,57 @@ resource "stackit_cdn_distribution" "example_bucket_distribution" { | |
| optimizer = { | ||
| enabled = false | ||
| } | ||
|
|
||
| redirects = { | ||
| rules = [ | ||
| { | ||
| description = "test redirect" | ||
| enabled = true | ||
| rule_match_condition = "ANY" | ||
| status_code = 302 | ||
| target_url = "https://stackit.de/" | ||
| matchers = [ | ||
| { | ||
| values = ["*/otherPath/"] | ||
| value_match_condition = "ANY" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| # WAF Configuration | ||
| # | ||
| # Precedence Hierarchy: Specific Rules > Groups > Collections | ||
| # In this example, the entire "@builtin/crs/request" collection is ENABLED. | ||
| # However, because specific Rule IDs have a higher precedence, the rule | ||
| # "@builtin/crs/request/942151" is explicitly DISABLED, overriding the collection setting. | ||
| # | ||
| # To view all available collections, groups, and rules, consult the API documentation: | ||
| # https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal docs are not reachable from external user |
||
| waf = { | ||
| mode = "ENABLED" | ||
| type = "PREMIUM" | ||
| paranoia_level = "L1" | ||
| allowed_http_versions = ["HTTP/1.0", "HTTP/1.1"] | ||
| allowed_http_methods = ["GET"] | ||
| allowed_request_content_types = ["text/plain"] | ||
|
|
||
| # Collections | ||
| enabled_rule_collection_ids = ["@builtin/crs/request"] | ||
| disabled_rule_collection_ids = [] | ||
| log_only_rule_collection_ids = ["@builtin/crs/response"] | ||
|
|
||
| # Groups | ||
| enabled_rule_group_ids = [] | ||
| disabled_rule_group_ids = [] | ||
| log_only_rule_group_ids = [] | ||
|
|
||
| # Specific Rules (Highest Precedence) | ||
| enabled_rule_ids = ["@builtin/crs/request/913100"] | ||
| disabled_rule_ids = ["@builtin/crs/request/942151"] | ||
| log_only_rule_ids = ["@builtin/crs/response/954120"] | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -96,6 +147,8 @@ Optional: | |
|
|
||
| - `blocked_countries` (List of String) The configured countries where distribution of content is blocked | ||
| - `optimizer` (Attributes) Configuration for the Image Optimizer. This is a paid feature that automatically optimizes images to reduce their file size for faster delivery, leading to improved website performance and a better user experience. (see [below for nested schema](#nestedatt--config--optimizer)) | ||
| - `redirects` (Attributes) A wrapper for a list of redirect rules that allows for redirect settings on a distribution (see [below for nested schema](#nestedatt--config--redirects)) | ||
| - `waf` (Attributes) Configuration of the Web Application Firewall (WAF) for the distribution. Removing this block from your configuration will completely disable the WAF. (see [below for nested schema](#nestedatt--config--waf)) | ||
|
|
||
| <a id="nestedatt--config--backend"></a> | ||
| ### Nested Schema for `config.backend` | ||
|
|
@@ -108,7 +161,7 @@ Optional: | |
|
|
||
| - `bucket_url` (String) The URL of the bucket (e.g. https://s3.example.com). Required if type is 'bucket'. | ||
| - `credentials` (Attributes) The credentials for the bucket. Required if type is 'bucket'. (see [below for nested schema](#nestedatt--config--backend--credentials)) | ||
| - `geofencing` (Map of List of String) The configured type http to configure countries where content is allowed. A map of URLs to a list of countries | ||
| - `geofencing` (Map of List of String) Routes users from specific countries to alternative origins (HTTP backend required). Configure this by mapping the alternative origin URL to a list of country codes | ||
| - `origin_request_headers` (Map of String) The configured type http origin request headers for the backend | ||
| - `origin_url` (String) The configured backend type http for the distribution | ||
| - `region` (String) The region where the bucket is hosted. Required if type is 'bucket'. | ||
|
|
@@ -131,6 +184,67 @@ Optional: | |
| - `enabled` (Boolean) | ||
|
|
||
|
|
||
| <a id="nestedatt--config--redirects"></a> | ||
| ### Nested Schema for `config.redirects` | ||
|
|
||
| Required: | ||
|
|
||
| - `rules` (Attributes List) A list of redirect rules. The order of rules matters for evaluation (see [below for nested schema](#nestedatt--config--redirects--rules)) | ||
|
|
||
| <a id="nestedatt--config--redirects--rules"></a> | ||
| ### Nested Schema for `config.redirects.rules` | ||
|
|
||
| Required: | ||
|
|
||
| - `matchers` (Attributes List) A list of matchers that define when this rule should apply. At least one matcher is required (see [below for nested schema](#nestedatt--config--redirects--rules--matchers)) | ||
| - `status_code` (Number) The HTTP status code for the redirect. Must be one of 301, 302, 303, 307, or 308. | ||
| - `target_url` (String) The target URL to redirect to. Must be a valid URI | ||
|
|
||
| Optional: | ||
|
|
||
| - `description` (String) An optional description for the redirect rule | ||
| - `enabled` (Boolean) A toggle to enable or disable the redirect rule. Default to true | ||
| - `rule_match_condition` (String) Defines how multiple matchers within this rule are combined (ALL, ANY, NONE). Defaults to ANY. | ||
|
|
||
| <a id="nestedatt--config--redirects--rules--matchers"></a> | ||
| ### Nested Schema for `config.redirects.rules.matchers` | ||
|
|
||
| Required: | ||
|
|
||
| - `values` (List of String) A list of glob patterns to match against the request path. At least one value is required. Examples: "/shop/*" or "*/img/*" | ||
|
|
||
| Optional: | ||
|
|
||
| - `value_match_condition` (String) Defines how multiple matchers within this rule are combined (ALL, ANY, NONE). Defaults to ANY. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| <a id="nestedatt--config--waf"></a> | ||
| ### Nested Schema for `config.waf` | ||
|
|
||
| Required: | ||
|
|
||
| - `mode` (String) The operating mode of the WAF. 'ENABLED' actively blocks threats, 'LOG_ONLY' logs matches without blocking, and 'DISABLED' completely turns off inspection. Defaults to 'DISABLED'. | ||
|
|
||
| Optional: | ||
|
|
||
| - `allowed_http_methods` (List of String) Restricts which HTTP methods the distribution accepts. If provided, the list must contain at least one item. If omitted, the API applies the following defaults: `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH`. | ||
| - `allowed_http_versions` (List of String) Restricts which HTTP protocol versions are accepted. If provided, the list must contain at least one item. If omitted, the API applies the following defaults: `HTTP/1.0`, `HTTP/1.1`, `HTTP/2`, `HTTP/2.0`. | ||
| - `allowed_request_content_types` (List of String) Restricts which Content-Type headers are accepted in request bodies. If provided, the list must contain at least one item. If omitted, the API applies the following defaults: `application/x-www-form-urlencoded`, `multipart/form-data`, `multipart/related`, `text/xml`, `application/xml`, `application/soap+xml`, `application/x-amf`, `application/json`, `application/octet-stream`, `application/csp-report`, `application/xss-auditor-report`, `text/plain`. | ||
| - `disabled_rule_collection_ids` (List of String) List of WAF Collection IDs explicitly disabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule collections, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| - `disabled_rule_group_ids` (List of String) List of WAF Rule Group IDs explicitly disabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule groups, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `disabled_rule_ids` (List of String) List of WAF rule IDs explicitly disabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. For example, an explicitly disabled Rule ID takes precedence over an enabled Group ID. To view available rules, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `enabled_rule_collection_ids` (List of String) List of WAF Collection IDs explicitly enabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule collections, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `enabled_rule_group_ids` (List of String) List of WAF Rule Group IDs explicitly enabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule groups, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `enabled_rule_ids` (List of String) List of WAF rule IDs explicitly enabled. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. For example, an explicitly enabled Rule ID takes precedence over a disabled Group ID. To view available rules, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `log_only_rule_collection_ids` (List of String) List of WAF Collection IDs explicitly marked as Log Only. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule collections, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `log_only_rule_group_ids` (List of String) List of WAF Rule Group IDs explicitly marked as Log Only. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rule groups, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `log_only_rule_ids` (List of String) List of WAF rule IDs explicitly marked as Log Only. Can be set to an empty list to clear previously set rules. Precedence hierarchy: Specific Rules override Groups, and Groups override Collections. To view available rules, please consult the API documentation: https://internal-docs.api.eu01.stackit.cloud/documentation/cdn/version/v1#tag/WAF/operation/ListWafCollections | ||
| - `paranoia_level` (String) Defines how aggressively the WAF should act on requests. Valid values are 'L1' to 'L4'. Defaults to 'L1'. | ||
| - `type` (String) The tier of the WAF. Valid values are 'FREE' or 'PREMIUM'. Defaults to 'FREE'. | ||
|
|
||
|
|
||
|
|
||
| <a id="nestedatt--domains"></a> | ||
| ### Nested Schema for `domains` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with the internal-docs
Should all be replaced