Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7c989aa
feat: add redirects in convertConfig
Mar 26, 2026
7cca33f
feat: add redirect in toCreatePayload
Mar 26, 2026
e850a14
feat: add redirect in the update function
Mar 26, 2026
cf6f255
feat: add in the map field mapfield
Mar 26, 2026
72d079c
small fix and add datasource
Mar 27, 2026
cafad57
chore: update doc
Mar 27, 2026
f2bcc1b
chore: add resource example
Mar 27, 2026
a5f9f48
Merge branch 'main' into mp/cdn/feat/implement-redirects
Mar 31, 2026
9addaea
chore: add redirect in acc test and address linter issues
Mar 31, 2026
618c3a2
chore: address linter issue
Mar 31, 2026
9a22cef
chore: add doc
Mar 31, 2026
83c4b94
Merge branch 'main' into mp/cdn/feat/implement-redirects
matheuspolitano Mar 31, 2026
6d30d9b
Merge branch 'main' into mp/cdn/feat/implement-redirects
Apr 1, 2026
cf12967
chore: adjust for the new sdk version
Apr 1, 2026
45905c6
chore: implement new sdk in cdn_acc_test
Apr 1, 2026
92dfd6f
Merge branch 'main' into mp/cdn/feat/implement-redirects
matheuspolitano Apr 7, 2026
9ccd292
Merge branch 'main' into mp/cdn/feat/implement-redirects
matheuspolitano Apr 8, 2026
56f3e9c
Merge branch 'main' into mp/cdn/feat/implement-redirects
matheuspolitano Apr 13, 2026
23d6bd9
feat: add waf in resource
Apr 12, 2026
731fb3f
feat: add waf in datasource
Apr 12, 2026
162d0d8
fix acc test
Apr 13, 2026
bd94faa
feat: improve waf to avoid state drift
Apr 13, 2026
312cca0
fyi: run fmt and fix linter issues
Apr 13, 2026
a15c7f7
feat: add doc and improve descriptions
Apr 13, 2026
d3929ad
fyi: improve some validations and description
Apr 13, 2026
100d9f6
fyi: add checks in acc_test
Apr 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions docs/data-sources/cdn_distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'.
Expand All @@ -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
- `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`
Expand Down
116 changes: 115 additions & 1 deletion docs/resources/cdn_distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

@h3adex h3adex Apr 14, 2026

Choose a reason for hiding this comment

The 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"]
}
}
}

Expand Down Expand Up @@ -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`
Expand All @@ -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'.
Expand All @@ -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
- `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`
Expand Down
Loading