commit 72a46c03a6b3881f7403b4584913ed6084d3b1d7 Author: Vojtech Mares Date: Sat Nov 27 12:15:22 2021 +0100 feat: initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..87a0020 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf +max_line_length = null + +[Makefile] +indent_style = tab diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit new file mode 100755 index 0000000..ee6f633 --- /dev/null +++ b/.git-hooks/pre-commit @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +make tf-fmt-check diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c035e72 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.terraform +.terraform.lock.hcl diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5b82042 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,7 @@ +include: + - project: mareshq/ci + file: terraform/modules.gitlab-ci.yml + ref: main + +variables: + TERRAFORM_MODULE_SYSTEM: cloudflare diff --git a/.releaserc.yml b/.releaserc.yml new file mode 100644 index 0000000..f00e742 --- /dev/null +++ b/.releaserc.yml @@ -0,0 +1,19 @@ +verifyConditions: + - "@semantic-release/gitlab" +prepare: +generateNotes: + - "@semantic-release/release-notes-generator" +publish: + - "@semantic-release/gitlab" +success: false +fail: false +npmPublish: false +tagFormat: ${version} +plugins: + - - "@semantic-release/commit-analyzer" + - preset: angular + parserOpts: + - "BREAKING CHANGE" + - "BREAKING CHANGES" + - "BREAKING" + - - "@semantic-release/release-notes-generator" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c9624e --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: setup-git-hooks +setup-git-hooks: + rm -rf .git/hooks + (cd .git && ln -s ../.git-hooks hooks) + +.PHONY: tf-fmt-check +tf-fmt-check: + terraform fmt -recursive -check + +.PHONY: tf-fmt +tf-fmt: + terraform fmt -recursive diff --git a/README.md b/README.md new file mode 100644 index 0000000..b359d71 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Terraform modules / Cloudflare zone + +Cloudflare zone for each domain to point nameservers to. diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..5349151 --- /dev/null +++ b/main.tf @@ -0,0 +1,16 @@ +resource "cloudflare_zone" "zone" { + zone = var.zone +} + +resource "cloudflare_zone_dnssec" "dnssec" { + zone_id = cloudflare_zone.zone.id +} + +resource "cloudflare_zone_settings_override" "settings_override" { + zone_id = cloudflare_zone.zone.id + settings { + always_use_https = var.always_use_https + automatic_https_rewrites = var.automatic_https_rewrites + ssl = var.ssl + } +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..9d0418a --- /dev/null +++ b/outputs.tf @@ -0,0 +1,3 @@ +output "zone" { + value = cloudflare_zone.zone +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..8c5cf92 --- /dev/null +++ b/variables.tf @@ -0,0 +1,18 @@ +variable "zone" { + type = string +} + +variable "always_use_https" { + type = string + default = "on" +} + +variable "automatic_https_rewrites" { + type = string + default = "on" +} + +variable "ssl" { + type = string + default = "full" +} diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..1002f0c --- /dev/null +++ b/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + cloudflare = { + source = "cloudflare/cloudflare" + version = ">=3.4.0" + } + } +}