Skip to content

Commit

Permalink
Adjust timeout and caching for Lambda Tilegarden and Run terraform fmt
Browse files Browse the repository at this point in the history
* Adjust Lambda Tilegarden CDN origin so that its timeout matches
  the lambda function and the Lambda function doesn't get cached
* Run terraform fmt to clean up some bad formatting
  • Loading branch information
Jean Cochrane committed Jan 30, 2019
1 parent 6282f7a commit a9a3cd3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
16 changes: 11 additions & 5 deletions deployment/terraform/cdn.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ resource "aws_cloudfront_distribution" "tilegarden" {
https_port = 443
origin_protocol_policy = "https-only"
origin_ssl_protocols = ["TLSv1.2", "TLSv1.1", "TLSv1"]
origin_read_timeout = 60
}

domain_name = "${var.tilegarden_api_gateway_domain_name}"
Expand All @@ -18,8 +19,9 @@ resource "aws_cloudfront_distribution" "tilegarden" {

origin {
custom_origin_config {
http_port = 80
https_port = 443
http_port = 80
https_port = 443

# S3 websites don't support TLS :/
origin_protocol_policy = "http-only"
origin_ssl_protocols = ["TLSv1.2", "TLSv1.1", "TLSv1"]
Expand Down Expand Up @@ -76,9 +78,13 @@ resource "aws_cloudfront_distribution" "tilegarden" {
}

viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = "300" # Five minutes
max_ttl = "86400" # One day

# Don't cache the Lambda origin at all, since the S3 cache bucket should
# always take precedence if the tile has been generated already.
min_ttl = 0

default_ttl = 0
max_ttl = 0
}

restrictions {
Expand Down
6 changes: 3 additions & 3 deletions deployment/terraform/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ resource "aws_iam_role_policy_attachment" "ecs_for_ec2_policy_container_instance
}

resource "aws_iam_instance_profile" "app_container_instance" {
name = "${aws_iam_role.app_container_instance_ec2.name}"
role = "${aws_iam_role.app_container_instance_ec2.name}"
name = "${aws_iam_role.app_container_instance_ec2.name}"
role = "${aws_iam_role.app_container_instance_ec2.name}"
}

#
Expand All @@ -189,6 +189,6 @@ resource "aws_iam_role_policy_attachment" "batch_ec2_s3_policy" {
}

resource "aws_iam_instance_profile" "batch_container_instance" {
name = "${aws_iam_role.batch_container_instance_ec2.name}"
name = "${aws_iam_role.batch_container_instance_ec2.name}"
role = "${aws_iam_role.batch_container_instance_ec2.name}"
}
8 changes: 5 additions & 3 deletions deployment/terraform/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ resource "aws_s3_bucket" "storage" {
}

lifecycle_rule {
id = "osm_extracts"
id = "osm_extracts"
enabled = true
prefix = "/osm-data-cache"
prefix = "/osm-data-cache"

expiration {
days = 7
}
Expand All @@ -58,7 +59,8 @@ resource "aws_s3_bucket" "tile_cache" {

website {
index_document = "index.html"
routing_rules = <<EOF

routing_rules = <<EOF
[{
"Condition": {
"HttpErrorCodeReturnedEquals": "404"
Expand Down
1 change: 1 addition & 0 deletions deployment/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ variable "pfb_app_alb_ingress_cidr_block" {

# CloudFront distribution
variable "tilegarden_api_gateway_domain_name" {}

variable "cloudfront_price_class" {
default = "PriceClass_100"
}

0 comments on commit a9a3cd3

Please sign in to comment.