generated from cncsc/template-terraform-module
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,260 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.3.4 | ||
1.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# PROVISION A CLOUDFLARE R2 BUCKET | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
|
||
required_providers { | ||
cloudflare = { | ||
source = "cloudflare/cloudflare" | ||
version = ">= 4.8.0" | ||
} | ||
|
||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
access_key = var.r2_access_key | ||
secret_key = var.r2_secret_key | ||
skip_credentials_validation = true | ||
skip_region_validation = true | ||
skip_requesting_account_id = true | ||
|
||
endpoints { | ||
s3 = "https://${var.account_id}.r2.cloudflarestorage.com" | ||
} | ||
} | ||
|
||
resource "cloudflare_r2_bucket" "bucket" { | ||
account_id = var.account_id | ||
name = var.name | ||
location = var.location_hint | ||
} | ||
|
||
resource "aws_s3_bucket_cors_configuration" "cors" { | ||
bucket = cloudflare_r2_bucket.bucket.id | ||
|
||
cors_rule { | ||
allowed_origins = ["*"] | ||
allowed_methods = [ | ||
"GET", | ||
"OPTIONS", | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "bucket_id" { | ||
value = cloudflare_r2_bucket.bucket.id | ||
description = "The ID of the R2 bucket." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# MODULE PARAMETERS | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
variable "account_id" { | ||
description = "The Cloudflare account ID where the bucket will be provisioned. This account must already be subscribed to R2." | ||
type = string | ||
} | ||
|
||
variable "r2_access_key" { | ||
description = "The R2 access key ID used to authenticate to the R2 service for this account." | ||
type = string | ||
} | ||
|
||
variable "r2_secret_key" { | ||
description = "The R2 secret key used to authenticate to the R2 service for this account." | ||
type = string | ||
} | ||
|
||
variable "name" { | ||
description = "The name of the R2 bucket. This must be unique per account." | ||
type = string | ||
} | ||
|
||
variable "location_hint" { | ||
description = "The location hint provided to suggest a region when provisioning the R2 bucket." | ||
type = string | ||
default = null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# PROVISION A CLOUDFLARE RECORD | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
|
||
required_providers { | ||
cloudflare = { | ||
source = "cloudflare/cloudflare" | ||
version = ">= 4.8.0" | ||
} | ||
} | ||
} | ||
|
||
# Because the Cloudflare provider treats `value` and `data` as exclusive properties (even when either has a null value) | ||
# we need to conditionally create these resources separately. | ||
|
||
resource "cloudflare_record" "record" { | ||
zone_id = var.zone_id | ||
name = var.name | ||
value = var.value | ||
type = var.type | ||
ttl = var.ttl | ||
priority = var.priority | ||
proxied = var.proxied | ||
comment = var.comment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
output "id" { | ||
value = cloudflare_record.record.id | ||
description = "The ID of the zone record." | ||
} | ||
|
||
output "hostname" { | ||
value = cloudflare_record.record.hostname | ||
description = "The fully qualified domain name (FQDN) of the record." | ||
} | ||
|
||
output "proxiable" { | ||
value = cloudflare_record.record.proxiable | ||
description = "Whether or not the record can be proxied by Cloudflare." | ||
} | ||
|
||
output "created_on" { | ||
value = cloudflare_record.record.created_on | ||
description = "The RFC3339 timestamp of when the record was created." | ||
} | ||
|
||
output "modified_on" { | ||
value = cloudflare_record.record.modified_on | ||
description = "The RFC3339 timestamp of when the record was last modified." | ||
} | ||
|
||
output "metadata" { | ||
value = cloudflare_record.record.metadata | ||
description = "A key-value map of string metadata Cloudflare associates with the record." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
# MODULE PARAMETERS | ||
# --------------------------------------------------------------------------------------------------------------------- | ||
|
||
variable "zone_id" { | ||
description = "The ID of the zone in which this record will be provisioned." | ||
type = string | ||
} | ||
|
||
variable "name" { | ||
description = "The name (or key) of the DNS record. Use `@` for the root zone." | ||
type = string | ||
} | ||
|
||
variable "value" { | ||
description = "The value of the DNS record." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "type" { | ||
description = "The type of DNS record being created." | ||
type = string | ||
} | ||
|
||
variable "ttl" { | ||
description = "The TTL specification (in seconds) of the DNS record being created. A value of `1` indicates `automatic`." | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "priority" { | ||
description = "The priority of the DNS record being created." | ||
type = number | ||
default = null | ||
} | ||
|
||
variable "proxied" { | ||
description = "Whether the record gets Cloudflare's origin protection." | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "comment" { | ||
description = "Comments or notes about this DNS record. This field has no effect on DNS responses." | ||
type = string | ||
default = "This record is managed by Terraform." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# PROVISION A CLOUDFLARE SERVICE RECORD | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
terraform { | ||
required_version = ">= 0.13" | ||
|
||
required_providers { | ||
cloudflare = { | ||
source = "cloudflare/cloudflare" | ||
version = ">= 4.8.0" | ||
} | ||
} | ||
} | ||
|
||
resource "cloudflare_record" "record" { | ||
zone_id = var.zone_id | ||
name = var.name | ||
type = var.type | ||
ttl = var.ttl | ||
priority = var.priority | ||
comment = var.comment | ||
|
||
data { | ||
service = var.service_type | ||
proto = var.service_protocol | ||
name = var.service_name | ||
priority = var.service_priority | ||
weight = var.service_weight | ||
port = var.service_port | ||
target = var.service_target | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
output "id" { | ||
value = cloudflare_record.record.id | ||
description = "The ID of the zone record." | ||
} | ||
|
||
output "hostname" { | ||
value = cloudflare_record.record.hostname | ||
description = "The fully qualified domain name (FQDN) of the record." | ||
} | ||
|
||
output "created_on" { | ||
value = cloudflare_record.record.created_on | ||
description = "The RFC3339 timestamp of when the record was created." | ||
} | ||
|
||
output "modified_on" { | ||
value = cloudflare_record.record.modified_on | ||
description = "The RFC3339 timestamp of when the record was last modified." | ||
} | ||
|
||
output "metadata" { | ||
value = cloudflare_record.record.metadata | ||
description = "A key-value map of string metadata Cloudflare associates with the record." | ||
} |
Oops, something went wrong.