-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
58 lines (50 loc) · 1.36 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
backend "remote" {
hostname = "app.terraform.io"
organization = "juliandawson"
workspaces {
name = "juliandawson-github-io"
}
}
}
provider "aws" {
region = "${var.aws_region}"
}
resource "aws_route53_zone" "dns_zone" {
name = "${var.dns_zone_name}"
}
# IP addresses for GitHub Pages can be found in the GitHub Docs:
# https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site
resource "aws_route53_record" "dns_record" {
zone_id = "${aws_route53_zone.dns_zone.id}"
name = "${var.dns_zone_name}"
type = "A"
records = [
"185.199.108.153",
"185.199.109.153",
"185.199.110.153",
"185.199.111.153"
]
ttl = 300
}
resource "aws_route53_record" "dns_record_www" {
zone_id = "${aws_route53_zone.dns_zone.id}"
name = "www.${var.dns_zone_name}"
type = "CNAME"
records = ["${var.github_username}.github.io."]
ttl = 300
}
resource "aws_route53_record" "dns_record_github_pages" {
zone_id = "${aws_route53_zone.dns_zone.id}"
name = "_github-pages-challenge-${var.github_username}.${var.dns_zone_name}"
type = "TXT"
records = ["${var.github_pages_code}"]
ttl = 300
}