Skip to content

Commit 189d228

Browse files
committed
fix IAM association at cloudfront
1 parent 49b24ae commit 189d228

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

terraform/modules/frontend/main.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ resource "aws_cloudfront_distribution" "app_cloudfront_distribution" {
101101
origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
102102
}
103103
}
104+
origin {
105+
origin_id = "IAMLambdaFunction"
106+
domain_name = var.IAMLambdaHost
107+
custom_origin_config {
108+
http_port = 80
109+
https_port = 443
110+
origin_protocol_policy = "https-only"
111+
origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
112+
}
113+
}
104114
default_root_object = "index.html"
105115
aliases = [var.CorePublicDomain]
106116
enabled = true
@@ -127,6 +137,20 @@ resource "aws_cloudfront_distribution" "app_cloudfront_distribution" {
127137
restriction_type = "none"
128138
}
129139
}
140+
ordered_cache_behavior {
141+
path_pattern = "/api/v1/iam*"
142+
target_origin_id = "IAMLambdaFunction"
143+
viewer_protocol_policy = "redirect-to-https"
144+
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
145+
cached_methods = ["GET", "HEAD"]
146+
cache_policy_id = aws_cloudfront_cache_policy.headers_no_cookies.id
147+
origin_request_policy_id = "b689b0a8-53d0-40ab-baf2-68738e2966ac"
148+
compress = true
149+
function_association {
150+
event_type = "viewer-request"
151+
function_arn = aws_cloudfront_function.origin_key_injection.arn
152+
}
153+
}
130154
ordered_cache_behavior {
131155
path_pattern = "/api/v1/events*"
132156
target_origin_id = "LambdaFunction"

terraform/modules/lambdas/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ data "archive_file" "sqs_lambda_code" {
1212

1313
locals {
1414
core_api_lambda_name = "${var.ProjectId}-main-server"
15-
core_api_iam_lambda_name = "${var.ProjectId}-iam-server"
15+
core_api_iam_lambda_name = "${var.ProjectId}-iam-write"
1616
core_sqs_consumer_lambda_name = "${var.ProjectId}-sqs-consumer"
1717
iam_policies = {
1818
shared = aws_iam_policy.shared_iam_policy.arn

0 commit comments

Comments
 (0)