Skip to content

Commit

Permalink
Merge pull request #17 from yohane-su/add-cloudflare
Browse files Browse the repository at this point in the history
Cloudflare providerでDNSレコードも管理する
  • Loading branch information
sksat authored Dec 19, 2021
2 parents 7045729 + 690d37e commit 1541cdd
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
32 changes: 32 additions & 0 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions terraform/dns.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
locals {
# GitHub Pages IP
# https://docs.github.com/ja/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site
gh_pages_ips = [
"185.199.108.153",
"185.199.109.153",
"185.199.110.153",
"185.199.111.153",
]
}

resource "cloudflare_record" "minecraft" {
zone_id = data.cloudflare_zone.yohanesu.id
name = "mc"
type = "A"
value = "45.76.188.189"
}

resource "cloudflare_record" "gh_pages" {
zone_id = data.cloudflare_zone.yohanesu.id
name = "yohane.su"
type = "A"
proxied = true

for_each = toset(local.gh_pages_ips)
value = each.value
}
13 changes: 13 additions & 0 deletions terraform/oci.tf → terraform/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ terraform {
source = "hashicorp/oci"
version = "4.57.0"
}

cloudflare = {
source = "cloudflare/cloudflare"
version = "3.5.0"
}
}
}

Expand All @@ -14,3 +19,11 @@ provider "oci" {
fingerprint = var.OCID_FINGERPRINT
private_key = var.OCID_PRIVATE_KEY
}

provider "cloudflare" {
api_token = var.CF_DNS_TOKEN
}

data "cloudflare_zone" "yohanesu" {
name = "yohane.su"
}
1 change: 1 addition & 0 deletions terraform/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ variable "OCID_COMPARTMENT" {}
variable "OCID_SUBNET" {}
variable "OCID_SOURCE" {}
variable "OCID_VCN" {}
variable "CF_DNS_TOKEN" {}

0 comments on commit 1541cdd

Please sign in to comment.