-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.tf
36 lines (31 loc) · 833 Bytes
/
resources.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
resource "aws_s3_bucket" "this" {
bucket = local.redirect_fqdn
}
resource "aws_s3_bucket_acl" "this" {
count = var.skip_acl ? 0 : 1
bucket = aws_s3_bucket.this.bucket
acl = "public-read"
}
resource "aws_s3_bucket_website_configuration" "this" {
bucket = aws_s3_bucket.this.bucket
index_document {
suffix = "index.html"
}
routing_rule {
redirect {
http_redirect_code = var.redirect_http_status_code
host_name = var.destination_hostname
protocol = var.destination_protocol
replace_key_with = var.destination_suffix
}
}
}
resource "aws_route53_record" "this" {
zone_id = var.redirect_route53_zone_id
name = local.redirect_fqdn
type = "CNAME"
ttl = 120
records = [
aws_s3_bucket_website_configuration.this.website_endpoint
]
}