Skip to content
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

Add records_default_proxied variable #48

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ Available targets:
| <a name="input_page_rules"></a> [page\_rules](#input\_page\_rules) | A list of maps of Page Rules.<br>The values of map is fully compliant with `cloudflare_page_rule` resource.<br>To get more info see https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/cloudflare_page_rule | `list(any)` | `null` | no |
| <a name="input_paused"></a> [paused](#input\_paused) | Whether this zone is paused (traffic bypasses Cloudflare) | `bool` | `false` | no |
| <a name="input_plan"></a> [plan](#input\_plan) | The name of the commercial plan to apply to the zone. Possible values: `free`, `pro`, `business`, `enterprise` | `string` | `"free"` | no |
| <a name="input_records"></a> [records](#input\_records) | name:<br> The name of the record.<br>type:<br> The type of the record.<br>value:<br> The value of the record.<br>comment:<br> Optional comment for the record.<br>ttl:<br> The TTL of the record.<br> Default value: 1.<br>priority:<br> The priority of the record.<br>proxied:<br> Whether the record gets Cloudflare's origin protection.<br> Default value: false. | `list(any)` | `[]` | no |
| <a name="input_records"></a> [records](#input\_records) | name:<br> The name of the record.<br>type:<br> The type of the record.<br>value:<br> The value of the record.<br>comment:<br> Optional comment for the record.<br>ttl:<br> The TTL of the record.<br> Default value: 1.<br>priority:<br> The priority of the record.<br>proxied:<br> Whether the record gets Cloudflare's origin protection.<br> Default value: Taken from records\_default\_proxied variable | `list(any)` | `[]` | no |
| <a name="input_records_default_proxied"></a> [records\_default\_proxied](#input\_records\_default\_proxied) | Default value for proxied | `bool` | `false` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
Expand Down
7 changes: 4 additions & 3 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

| Name | Version |
|------|---------|
| <a name="provider_cloudflare"></a> [cloudflare](#provider\_cloudflare) | 4.34.0 |
| <a name="provider_time"></a> [time](#provider\_time) | 0.11.2 |
| <a name="provider_cloudflare"></a> [cloudflare](#provider\_cloudflare) | >= 4.0 |
| <a name="provider_time"></a> [time](#provider\_time) | >= 0.8 |

## Modules

Expand Down Expand Up @@ -59,7 +59,8 @@
| <a name="input_page_rules"></a> [page\_rules](#input\_page\_rules) | A list of maps of Page Rules.<br>The values of map is fully compliant with `cloudflare_page_rule` resource.<br>To get more info see https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/cloudflare_page_rule | `list(any)` | `null` | no |
| <a name="input_paused"></a> [paused](#input\_paused) | Whether this zone is paused (traffic bypasses Cloudflare) | `bool` | `false` | no |
| <a name="input_plan"></a> [plan](#input\_plan) | The name of the commercial plan to apply to the zone. Possible values: `free`, `pro`, `business`, `enterprise` | `string` | `"free"` | no |
| <a name="input_records"></a> [records](#input\_records) | name:<br> The name of the record.<br>type:<br> The type of the record.<br>value:<br> The value of the record.<br>ttl:<br> The TTL of the record.<br> Default value: 1.<br>priority:<br> The priority of the record.<br>proxied:<br> Whether the record gets Cloudflare's origin protection.<br> Default value: false. | `list(any)` | `[]` | no |
| <a name="input_records"></a> [records](#input\_records) | name:<br> The name of the record.<br>type:<br> The type of the record.<br>value:<br> The value of the record.<br>comment:<br> Optional comment for the record.<br>ttl:<br> The TTL of the record.<br> Default value: 1.<br>priority:<br> The priority of the record.<br>proxied:<br> Whether the record gets Cloudflare's origin protection.<br> Default value: Taken from records\_default\_proxied variable | `list(any)` | `[]` | no |
| <a name="input_records_default_proxied"></a> [records\_default\_proxied](#input\_records\_default\_proxied) | Default value for proxied | `bool` | `false` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ locals {
for index, record in var.records :
try(record.key, format("%s-%s-%s", record.name, record.type, record.value)) => record
} : {}
records_default_proxied = var.records_default_proxied
}

data "cloudflare_zones" "default" {
Expand Down Expand Up @@ -40,7 +41,7 @@ resource "cloudflare_record" "default" {
value = each.value.value
comment = lookup(each.value, "comment", null)
priority = lookup(each.value, "priority", null)
proxied = lookup(each.value, "proxied", false)
proxied = lookup(each.value, "proxied", local.records_default_proxied)
ttl = lookup(each.value, "ttl", 1)
}

Expand Down
8 changes: 7 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ variable "records" {
The priority of the record.
proxied:
Whether the record gets Cloudflare's origin protection.
Default value: false.
Default value: Taken from records_default_proxied variable
DOC
}

variable "records_default_proxied" {
type = bool
description = "Default value for proxied"
default = false
}

variable "paused" {
type = bool
description = "Whether this zone is paused (traffic bypasses Cloudflare)"
Expand Down