From e4fa5990f48af3f1e2c5218e7de86d5518533c53 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 4 Mar 2022 17:45:04 +0100 Subject: [PATCH] more terraform boilerplates --- terraform/cloudflare/credentials.tf | 13 +++++++++++ terraform/cloudflare/dns.tf | 12 ++++++++++ terraform/cloudflare/provider.tf | 19 +++++++++++++++ terraform/kubernetes/provider.tf | 23 +++++++++++++++++++ .../cloud-deployment-example/civo.tf | 0 .../cloud-deployment-example/cloudflare.tf | 0 .../cloud-deployment-example/main.tf | 0 .../simple-docker-example/main.tf | 0 8 files changed, 67 insertions(+) create mode 100644 terraform/cloudflare/credentials.tf create mode 100644 terraform/cloudflare/dns.tf create mode 100644 terraform/cloudflare/provider.tf create mode 100644 terraform/kubernetes/provider.tf rename terraform/{examples => templates}/cloud-deployment-example/civo.tf (100%) rename terraform/{examples => templates}/cloud-deployment-example/cloudflare.tf (100%) rename terraform/{examples => templates}/cloud-deployment-example/main.tf (100%) rename terraform/{examples => templates}/simple-docker-example/main.tf (100%) diff --git a/terraform/cloudflare/credentials.tf b/terraform/cloudflare/credentials.tf new file mode 100644 index 0000000..69646d4 --- /dev/null +++ b/terraform/cloudflare/credentials.tf @@ -0,0 +1,13 @@ +# Cloudflare Credentials +# --- +# Credential Variables needed for Cloudflare + +# Cloudflare Config +variable "cloudflare_email" { + description = "The email address for your Cloudflare account" + type = string +} +variable "cloudflare_api_key" { + description = "The API key for your Cloudflare account" + type = string +} \ No newline at end of file diff --git a/terraform/cloudflare/dns.tf b/terraform/cloudflare/dns.tf new file mode 100644 index 0000000..a67f02e --- /dev/null +++ b/terraform/cloudflare/dns.tf @@ -0,0 +1,12 @@ +# Cloudflare DNS +# --- +# Templates to manage DNS Records on Cloudflare + +# A Record +resource "cloudflare_record" "your-dns-record-name" { + zone_id = "your-zone-id" + name = "your-public-dns-value" + value = "your-public-ip-address" + type = "A" + proxied = false # set to true, to hide public IP +} diff --git a/terraform/cloudflare/provider.tf b/terraform/cloudflare/provider.tf new file mode 100644 index 0000000..2db704d --- /dev/null +++ b/terraform/cloudflare/provider.tf @@ -0,0 +1,19 @@ +# Cloudflare Provider +# --- +# Initial Provider Configuration for Cloudflare + +terraform { + required_version = ">= 0.13.0" + + required_providers { + cloudflare = { + source = "cloudflare/cloudflare" + version = "~> 3.0" + } + } +} + +provider "cloudflare" { + email = var.cloudflare_email + api_key = var.cloudflare_api_key +} diff --git a/terraform/kubernetes/provider.tf b/terraform/kubernetes/provider.tf new file mode 100644 index 0000000..8cd2e1e --- /dev/null +++ b/terraform/kubernetes/provider.tf @@ -0,0 +1,23 @@ +# Kubectl Provider +# --- +# Initial Provider Configuration for Kubectl + +terraform { + required_version = ">= 0.13.0" + + required_providers { + kubectl = { + source = "gavinbunney/kubectl" + version = "1.13.1" + } + } +} + +# Dynamic Configuration from CIVO Kubernetes deployment +# provider "kubectl" { +# host = "${yamldecode(civo_kubernetes_cluster.your-kubernetes-cluster.kubeconfig).clusters.0.cluster.server}" +# client_certificate = "${base64decode(yamldecode(civo_kubernetes_cluster.your-kubernetes-cluster.kubeconfig).users.0.user.client-certificate-data)}" +# client_key = "${base64decode(yamldecode(civo_kubernetes_cluster.your-kubernetes-cluster.kubeconfig).users.0.user.client-key-data)}" +# cluster_ca_certificate = "${base64decode(yamldecode(civo_kubernetes_cluster.your-kubernetes-cluster.kubeconfig).clusters.0.cluster.certificate-authority-data)}" +# load_config_file = false +# } \ No newline at end of file diff --git a/terraform/examples/cloud-deployment-example/civo.tf b/terraform/templates/cloud-deployment-example/civo.tf similarity index 100% rename from terraform/examples/cloud-deployment-example/civo.tf rename to terraform/templates/cloud-deployment-example/civo.tf diff --git a/terraform/examples/cloud-deployment-example/cloudflare.tf b/terraform/templates/cloud-deployment-example/cloudflare.tf similarity index 100% rename from terraform/examples/cloud-deployment-example/cloudflare.tf rename to terraform/templates/cloud-deployment-example/cloudflare.tf diff --git a/terraform/examples/cloud-deployment-example/main.tf b/terraform/templates/cloud-deployment-example/main.tf similarity index 100% rename from terraform/examples/cloud-deployment-example/main.tf rename to terraform/templates/cloud-deployment-example/main.tf diff --git a/terraform/examples/simple-docker-example/main.tf b/terraform/templates/simple-docker-example/main.tf similarity index 100% rename from terraform/examples/simple-docker-example/main.tf rename to terraform/templates/simple-docker-example/main.tf