forked from jeofy/terraform-amazon-route53
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
82 lines (71 loc) · 2.03 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
backend "remote" {
hostname = "app.terraform.io"
organization = "changeinpractice"
workspaces {
name = "changeinpractice-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
}
resource "aws_route53_record" "dns_record_mail" {
zone_id = aws_route53_zone.dns_zone.id
name = var.dns_zone_name
type = "MX"
records = ["0 ${replace(var.dns_zone_name, ".", "-")}.mail.protection.outlook.com."]
ttl = 300
}
resource "aws_route53_record" "dns_record_autodiscover" {
zone_id = aws_route53_zone.dns_zone.id
name = "autodiscover.${var.dns_zone_name}"
type = "CNAME"
records = ["autodiscover.outlook.com."]
ttl = 300
}
resource "aws_route53_record" "dns_record_spf" {
zone_id = aws_route53_zone.dns_zone.id
name = var.dns_zone_name
type = "TXT"
records = ["v=spf1 include:spf.protection.outlook.com -all"]
ttl = 300
}