-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
32 lines (26 loc) · 796 Bytes
/
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
data "aws_route53_zone" "this" {
name = var.route53_domain
}
resource "aws_s3_bucket" "this" {
bucket = "${var.subdomain}.${data.aws_route53_zone.this.name}"
}
locals {
redirect_split = split("://", var.redirect_url)
}
resource "aws_s3_bucket_website_configuration" "this" {
bucket = aws_s3_bucket.this.id
redirect_all_requests_to {
protocol = local.redirect_split[0]
host_name = local.redirect_split[1]
}
}
resource "aws_route53_record" "this" {
zone_id = data.aws_route53_zone.this.id
name = "${var.subdomain}.${data.aws_route53_zone.this.name}"
type = "A"
alias {
name = aws_s3_bucket_website_configuration.this.website_domain
zone_id = aws_s3_bucket.this.hosted_zone_id
evaluate_target_health = true
}
}