Skip to content

Commit

Permalink
๐Ÿ”€ :: cloudflare dns ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜
Browse files Browse the repository at this point in the history
๐Ÿ”€ :: cloudflare dns ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜
  • Loading branch information
jeongho1209 authored Nov 8, 2023
2 parents c05bff7 + 8104744 commit 7cbca33
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 2 deletions.
115 changes: 115 additions & 0 deletions cloudflare.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
provider "cloudflare" {
api_token = var.cloudflare_api_token
}

locals {
a_record_type = "A"
cname_record_type = "CNAME"

xquare_design_record_name = "design"
xquare_mysql_record_name = "mysql"
xquare_redis_record_name = "redis"
xquare_server_record_names = [
"admin",
"argo-cd",
"cloud-config",
"dex-login",
"dex",
"grafana",
"infisical",
"jaeger",
"keycloak",
"kiali",
"oidc-proxy",
"prod-server",
"project",
"service",
"stag-server",
"thanos-store",
"thanos",
]
pick_server_record_names = [
"admin",
"teacher",
]
repo_on_premise_record_names = [
"admin",
"mariadb",
"mongodb",
"server",
]
repo_server_record_names = [
"api",
"teacher",
"test",
"user",
"www",
]
}

resource "cloudflare_record" "xquare_server_record" {
for_each = toset(local.xquare_server_record_names)
name = each.value
proxied = false
ttl = 1
type = local.cname_record_type
value = var.xquare_server_domain
zone_id = var.xquare_cloudflare_zone_id
}

resource "cloudflare_record" "pick_server_record" {
for_each = toset(local.pick_server_record_names)
name = each.value
proxied = false
ttl = 1
type = local.cname_record_type
value = var.xquare_server_domain
zone_id = var.pick_cloudflare_zone_id
}

resource "cloudflare_record" "repo_server_record" {
for_each = toset(local.repo_server_record_names)
name = each.value
proxied = false
ttl = 1
type = local.cname_record_type
value = var.xquare_server_domain
zone_id = var.repo_cloudflare_zone_id
}

resource "cloudflare_record" "repo_on_premise_record" {
for_each = toset(local.repo_on_premise_record_names)
name = each.value
proxied = false
ttl = 1
type = local.a_record_type
value = var.repo_on_premise_ip
zone_id = var.repo_cloudflare_zone_id
}

resource "cloudflare_record" "xquare_design_record" {
name = local.xquare_design_record_name
proxied = false
ttl = 1
type = local.cname_record_type
value = var.xquare_design_domain
zone_id = var.xquare_cloudflare_zone_id
}

resource "cloudflare_record" "xquare_mysql_record" {
name = local.xquare_mysql_record_name
proxied = false
ttl = 1
type = local.cname_record_type
value = var.xquare_mysql_domain
zone_id = var.xquare_cloudflare_zone_id
}

resource "cloudflare_record" "xquare_redis_record" {
name = local.xquare_redis_record_name
proxied = false
ttl = 1
type = local.cname_record_type
value = var.xquare_redis_domain
zone_id = var.xquare_cloudflare_zone_id
}
File renamed without changes.
4 changes: 4 additions & 0 deletions provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ terraform {
source = "hashicorp/aws"
version = "~> 4.46"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.0"
}
}
cloud {
hostname = "app.terraform.io"
Expand Down
39 changes: 37 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
variable "rds_master_password" {
type = string
default = "password"
type = string
}

variable "cloudflare_api_token" {
type = string
}

variable "xquare_cloudflare_zone_id" {
type = string
}

variable "pick_cloudflare_zone_id" {
type = string
}

variable "repo_cloudflare_zone_id" {
type = string
}

variable "xquare_server_domain" {
type = string
}

variable "xquare_design_domain" {
type = string
}

variable "xquare_mysql_domain" {
type = string
}

variable "xquare_redis_domain" {
type = string
}

variable "repo_on_premise_ip" {
type = string
}

0 comments on commit 7cbca33

Please sign in to comment.