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 account_id to allow module to function #24

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ usage: |-
source = "cloudposse/zone/cloudflare"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
account_id = "example-account-id"
JohnShortland marked this conversation as resolved.
Show resolved Hide resolved
zone = "cloudposse.co"
records = [
{
Expand Down
2 changes: 2 additions & 0 deletions examples/complete/fixtures.us-east-2.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ stage = "test"
name = "cf-zone"

zone = "test-automation.app"

account_id = "example-account-id"
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module "zone" {
source = "../.."

account_id = var.account_id
zone = var.zone
zone_enabled = false
argo_enabled = false
Expand Down
5 changes: 5 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ variable "zone" {
type = string
description = "The DNS zone name which will be added."
}

variable "account_id" {
type = string
description = "Cloudflare account ID to manage the zone resource in"
}
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ locals {
smart_routing = local.argo_enabed && var.argo_smart_routing_enabled ? "on" : "off"
argo_enabed = module.this.enabled && var.argo_enabled
zone_enabled = module.this.enabled && var.zone_enabled
zone_exists = module.this.enabled && ! var.zone_enabled
zone_exists = module.this.enabled && !var.zone_enabled
records_enabled = module.this.enabled && length(var.records) > 0
zone_id = local.zone_enabled ? join("", cloudflare_zone.default.*.id) : (local.zone_exists ? lookup(data.cloudflare_zones.default[0].zones[0], "id") : null)
JohnShortland marked this conversation as resolved.
Show resolved Hide resolved
records = local.records_enabled ? {
Expand All @@ -23,6 +23,7 @@ data "cloudflare_zones" "default" {
resource "cloudflare_zone" "default" {
count = local.zone_enabled ? 1 : 0

account_id = var.account_id
zone = var.zone
paused = var.paused
jump_start = var.jump_start
Expand Down
19 changes: 12 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ variable "zone" {
description = "The DNS zone name which will be added."
}

variable "account_id" {
type = string
description = "Cloudflare account ID to manage the zone resource in"
}

variable "zone_enabled" {
type = bool
description = "Whether to create DNS zone otherwise use existing."
Expand All @@ -23,9 +28,9 @@ variable "records" {
The TTL of the record.
Default value: 1.
priority:
The priority of the record.
The priority of the record.
proxied:
Whether the record gets Cloudflare's origin protection.
Whether the record gets Cloudflare's origin protection.
Default value: false.
DOC
}
Expand Down Expand Up @@ -86,7 +91,7 @@ variable "healthchecks" {
type = list(any)
default = null
description = <<-DOC
A list of maps of Health Checks rules.
A list of maps of Health Checks rules.
The values of map is fully compliant with `cloudflare_healthcheck` resource.
To get more info see https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/healthcheck
DOC
Expand All @@ -105,14 +110,14 @@ variable "firewall_rules" {
ref:
Short reference tag to quickly select related rules.
action:
The action to apply to a matched request.
The action to apply to a matched request.
Possible values: `block`, `challenge`, `allow`, `js_challenge`, `bypass`.
priority:
The priority of the rule to allow control of processing order.
The priority of the rule to allow control of processing order.
A lower number indicates high priority.
If not provided, any rules with a priority will be sequenced before those without.
products:
List of products to bypass for a request when the bypass action is used.
List of products to bypass for a request when the bypass action is used.
Possible values: `zoneLockdown`, `uaBlock`, `bic`, `hot`, `securityLevel`, `rateLimit`, `waf`.
DOC
}
Expand All @@ -121,7 +126,7 @@ variable "page_rules" {
type = list(any)
default = null
description = <<-DOC
A list of maps of Page Rules.
A list of maps of Page Rules.
The values of map is fully compliant with `cloudflare_page_rule` resource.
To get more info see https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/cloudflare_page_rule
DOC
Expand Down