Skip to content

Commit 2d1a7f0

Browse files
committed
Use Terraform vars for config
1 parent 7124ef2 commit 2d1a7f0

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Getting Started with Create React App
1+
# mattertwo.github.io
22

33
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
44

@@ -44,3 +44,24 @@ You don’t have to ever use `eject`. The curated feature set is suitable for sm
4444
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
4545

4646
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
## Terraform configuration
49+
50+
The following variables can be used to configure the infrastructure.
51+
52+
### Variable sets
53+
54+
##### AWS
55+
56+
| Name | Default | Description |
57+
| --------------------- | ------- | ----------- |
58+
| AWS_ACCESS_KEY_ID | |
59+
| AWS_SECRET_ACCESS_KEY | |
60+
61+
### Variables
62+
63+
| Name | Default | Description |
64+
| ----------------- | ------- | ----------- |
65+
| dns_zone_name | |
66+
| github_username | |
67+
| github_pages_code | |
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "aws_route53_record" "dns_record" {
22
zone_id = aws_route53_zone.dns_zone.id
3-
name = aws_route53_zone.dns_zone.name
3+
name = var.dns_zone_name
44
type = "A"
55
records = [
66
"185.199.108.153",
@@ -13,40 +13,40 @@ resource "aws_route53_record" "dns_record" {
1313

1414
resource "aws_route53_record" "dns_record_www" {
1515
zone_id = aws_route53_zone.dns_zone.id
16-
name = "www.${aws_route53_zone.dns_zone.name}"
16+
name = "www.${var.dns_zone_name}"
1717
type = "CNAME"
18-
records = ["mattertwo.github.io."]
18+
records = ["${var.github_username}.github.io."]
1919
ttl = 300
2020
}
2121

2222
resource "aws_route53_record" "dns_record_mail" {
2323
zone_id = aws_route53_zone.dns_zone.id
24-
name = aws_route53_zone.dns_zone.name
24+
name = var.dns_zone_name
2525
type = "MX"
26-
records = ["0 mattertwo-com.mail.protection.outlook.com."]
26+
records = ["0 ${replace(var.dns_zone_name, ".", "-")}.mail.protection.outlook.com."]
2727
ttl = 300
2828
}
2929

3030
resource "aws_route53_record" "dns_record_autodiscover" {
3131
zone_id = aws_route53_zone.dns_zone.id
32-
name = "autodiscover.${aws_route53_zone.dns_zone.name}"
32+
name = "autodiscover.${var.dns_zone_name}"
3333
type = "CNAME"
3434
records = ["autodiscover.outlook.com."]
3535
ttl = 300
3636
}
3737

3838
resource "aws_route53_record" "dns_record_spf" {
3939
zone_id = aws_route53_zone.dns_zone.id
40-
name = aws_route53_zone.dns_zone.name
40+
name = var.dns_zone_name
4141
type = "TXT"
4242
records = ["v=spf1 include:spf.protection.outlook.com -all"]
4343
ttl = 300
4444
}
4545

4646
resource "aws_route53_record" "dns_record_github_pages" {
4747
zone_id = aws_route53_zone.dns_zone.id
48-
name = "_github-pages-challenge-mattertwo.${aws_route53_zone.dns_zone.name}"
48+
name = "_github-pages-challenge-${var.github_username}.${var.dns_zone_name}"
4949
type = "TXT"
50-
records = ["dee22f0f20c4b1262f021d6406582a"]
50+
records = [var.github_pages_code]
5151
ttl = 300
5252
}

infrastructure/aws_route53_zone.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
resource "aws_route53_zone" "dns_zone" {
2-
name = "mattertwo.com"
2+
name = var.dns_zone_name
33
}

infrastructure/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "dns_zone_name" {
2+
type = string
3+
}
4+
5+
variable "github_username" {
6+
type = string
7+
}
8+
9+
variable "github_pages_code" {
10+
type = string
11+
}

0 commit comments

Comments
 (0)