Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/flaconi/terraform-cloudflare-rulesets

This module will create Cloudflare Rulesets
https://github.com/flaconi/terraform-cloudflare-rulesets

cloudflare terraform terraform-module

Last synced: about 4 hours ago
JSON representation

This module will create Cloudflare Rulesets

Awesome Lists containing this project

README

        

# Terraform module: Cloudflare Rulesets

This Terraform module manages Cloudflare Rulesets.

[![lint](https://github.com/flaconi/terraform-cloudflare-rulesets/workflows/lint/badge.svg)](https://github.com/flaconi/terraform-cloudflare-rulesets/actions?query=workflow%3Alint)
[![test](https://github.com/flaconi/terraform-cloudflare-rulesets/workflows/test/badge.svg)](https://github.com/flaconi/terraform-cloudflare-rulesets/actions?query=workflow%3Atest)
[![Tag](https://img.shields.io/github/tag/flaconi/terraform-cloudflare-rulesets.svg)](https://github.com/flaconi/terraform-cloudflare-rulesets/releases)
[![Terraform](https://img.shields.io/badge/Terraform--registry-cloudflare--rulesets-brightgreen.svg)](https://registry.terraform.io/modules/flaconi/rulesets/cloudflare/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## Providers

| Name | Version |
|------|---------|
| [cloudflare](#provider\_cloudflare) | ~> 4.20 |

## Requirements

| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | ~> 1.3 |
| [cloudflare](#requirement\_cloudflare) | ~> 4.20 |

## Required Inputs

The following input variables are required:

### [api\_token](#input\_api\_token)

Description: The Cloudflare API token.

Type: `string`

### [domain](#input\_domain)

Description: Cloudflare domain to apply rules for.

Type: `string`

### [name](#input\_name)

Description: Name of the ruleset.

Type: `string`

### [kind](#input\_kind)

Description: Type of Ruleset to create.

Type: `string`

### [phase](#input\_phase)

Description: Point in the request/response lifecycle where the ruleset will be created.

Type: `string`

## Optional Inputs

The following input variables are optional (have default values):

### [description](#input\_description)

Description: Brief summary of the ruleset and its intended use.

Type: `string`

Default: `null`

### [rules](#input\_rules)

Description: List of Cloudflare rule objects.

Type:

```hcl
list(object({
expression = string
action = string
action_parameters = optional(object({
# phase: http_config_settings, action: set_config
polish = optional(string)

# phase: http_log_custom_fields, action: log_custom_field
cookie_fields = optional(list(string))
request_fields = optional(list(string))
response_fields = optional(list(string))

# phase: http_request_dynamic_redirect, action: redirect
from_value = optional(object({
preserve_query_string = optional(bool)
status_code = number
target_url = object({
value = optional(string)
expression = optional(string)
})
}), null)

# phase: http_request_firewall_custom, action: block, challenge, js_challenge, log, managed_challenge, skip
phases = optional(list(string))
products = optional(list(string))
ruleset = optional(string)

# phase: http_request_firewall_managed, action: block, challenge, js_challenge, log, managed_challenge, skip
id = optional(string)
version = optional(string)
overrides = optional(object({
action = optional(string)
categories = optional(list(object({
action = optional(string)
category = string
enabled = bool
})), [])
enabled = optional(bool)
rules = optional(list(object({
id = string
action = string
enabled = bool
score_threshold = optional(number)
})), [])
}), null)

# phase: http_request_origin, action: route
host_header = optional(string)
origin = optional(object({
host = optional(string)
port = optional(number)
}), null)

# phase: http_request_transform
uri = optional(object({
path = optional(string)
query = optional(string)
}))
}), null)
# phase: http_ratelimit, action: block, challenge, js_challenge, log, managed_challenge
ratelimit = optional(object({
characteristics = optional(list(string))
counting_expression = optional(string)
mitigation_timeout = optional(number)
period = optional(number)
requests_per_period = optional(number)
requests_to_origin = optional(bool)
score_per_period = optional(number)
score_response_header_name = optional(string)
}), null)
description = optional(string)
enabled = optional(bool, true)
logging = optional(object({
enabled = bool
}), null)
}))
```

Default: `[]`

## Outputs

| Name | Description |
|------|-------------|
| [domain](#output\_domain) | Current zone information. |
| [rules](#output\_rules) | Created Cloudflare rules for the current zone. |

## License

**[MIT License](LICENSE)**

Copyright (c) 2024 **[Flaconi GmbH](https://github.com/flaconi)**