-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3.tf
45 lines (36 loc) · 963 Bytes
/
s3.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
resource "aws_s3_bucket" "this" {
bucket = "${var.name}-${var.environment}"
force_destroy = true
}
resource "aws_s3_bucket_acl" "this" {
bucket = aws_s3_bucket.this.id
acl = "public-read"
}
resource "aws_s3_bucket_cors_configuration" "this" {
bucket = aws_s3_bucket.this.bucket
cors_rule {
allowed_headers = ["*"]
allowed_methods = ["GET", "POST"]
allowed_origins = [var.fqdn_alias]
expose_headers = ["ETag"]
max_age_seconds = 3000
}
}
resource "aws_s3_bucket_website_configuration" "this" {
bucket = aws_s3_bucket.this.bucket
index_document {
suffix = "index.html"
}
error_document {
key = "index.html"
}
}
resource "time_sleep" "wait_5_seconds" {
depends_on = [aws_s3_bucket.this]
create_duration = "5s"
}
resource "aws_s3_bucket_policy" "this" {
depends_on = [time_sleep.wait_5_seconds]
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.bucket.json
}