-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprod.tf
More file actions
66 lines (57 loc) · 1.83 KB
/
prod.tf
File metadata and controls
66 lines (57 loc) · 1.83 KB
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
module "prod_site" {
source = "./modules/phlask-baseline-resources"
env_name = "prod"
default_cache_behavior = {
default_ttl = 300
max_ttl = 600
function_association = [
{
event_type = "viewer-request"
function_arn = aws_cloudfront_function.www_redirect.arn
}
]
}
ordered_cache_behavior = [
{
path_pattern = "submit-image"
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]
cache_policy_id = data.aws_cloudfront_cache_policy.caching_optimized.id
lambda_function_association = [
{
event_type = "viewer-request"
include_body = false
lambda_arn = aws_lambda_function.image_submission_handler.qualified_arn
}
]
},
{
path_pattern = "/images/*"
allowed_methods = ["GET","HEAD"]
cached_methods = ["GET","HEAD"]
cache_policy_id = data.aws_cloudfront_cache_policy.caching_optimized.id
target_origin_id = local.images_origin_id
function_association = [
{
event_type = "viewer-request"
function_arn = aws_cloudfront_function.image-path-cleanup.arn
}
]
}
]
common_domain = var.common_domain
additional_aliases = ["www.${var.common_domain}"]
origin_access_control_id_images = aws_cloudfront_origin_access_control.images.id
phlask_images_bucket_name = aws_s3_bucket.images.id
phlask_logs_bucket_name = aws_s3_bucket.logs.id
providers = {
aws.us-east-1 = aws.us-east-1
}
}
resource "aws_cloudfront_function" "www_redirect" {
name = "www-redirect"
comment = "Managed by Terraform"
runtime = "cloudfront-js-2.0"
publish = true
code = file("${path.module}/src_code/www-redirect/function.js")
}