Skip to content

Commit

Permalink
Pass correct tile cache endpoint to CDN and Tilegarden
Browse files Browse the repository at this point in the history
Fix two issues with the tile cache endpoint:

* Make sure the CDN has the right endpoint
* Make sure that Tilegarden configures environment variables
  • Loading branch information
Jean Cochrane committed Jan 29, 2019
1 parent e79f679 commit 6282f7a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion deployment/terraform/cdn.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ resource "aws_cloudfront_distribution" "tilegarden" {
}

origin {
domain_name = "${aws_s3_bucket.tile_cache.bucket_regional_domain_name}"
custom_origin_config {
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"]
}

domain_name = "${aws_s3_bucket.tile_cache.website_endpoint}"
origin_id = "tilegardenCacheOriginEastId"

custom_header {
Expand Down
1 change: 1 addition & 0 deletions src/tilegarden/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ PFB_DB_DATABASE=
PFB_DB_PASSWORD=
PFB_DB_PORT=
PFB_DB_USER=
PFB_TILEGARDEN_CACHE_BUCKET=
4 changes: 2 additions & 2 deletions src/tilegarden/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
],
"scripts": {
"build-all-xml": "./scripts/build-all-xml.sh src/config src/config",
"deploy": "yarn compile && claudia update --no-optional-dependencies ${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} ${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} ${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} ${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}}",
"deploy-new": "yarn compile && claudia create --no-optional-dependencies --api-module dist/api --name ${PROJECT_NAME} --region ${LAMBDA_REGION} ${LAMBDA_ROLE:+--role ${LAMBDA_ROLE}} ${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} ${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} ${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} ${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}} && yarn parse-id",
"deploy": "yarn compile && claudia update --no-optional-dependencies ${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} ${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} ${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} ${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}} ${PFB_TILEGARDEN_CACHE_BUCKET:+--set-env PFB_TILEGARDEN_CACHE_BUCKET=${PFB_TILEGARDEN_CACHE_BUCKET}}",
"deploy-new": "yarn compile && claudia create --no-optional-dependencies --api-module dist/api --name ${PROJECT_NAME} --region ${LAMBDA_REGION} ${LAMBDA_ROLE:+--role ${LAMBDA_ROLE}} ${LAMBDA_TIMEOUT:+--timeout ${LAMBDA_TIMEOUT}} ${LAMBDA_MEMORY:+--memory ${LAMBDA_MEMORY}} ${LAMBDA_SECURITY_GROUPS:+--security-group-ids ${LAMBDA_SECURITY_GROUPS}} ${LAMBDA_SUBNETS:+--subnet-ids ${LAMBDA_SUBNETS}} ${PFB_TILEGARDEN_CACHE_BUCKET:+--set-env PFB_TILEGARDEN_CACHE_BUCKET=${PFB_TILEGARDEN_CACHE_BUCKET}} && yarn parse-id",
"destroy": "claudia destroy",
"dev": "nodemon -e js,mss,json,mml,mss --ignore dist/ --ignore '*.temp.mml' --exec yarn local",
"lint": "eslint src",
Expand Down
4 changes: 4 additions & 0 deletions src/tilegarden/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const writeToS3 = (tile, req) => {
const { z, x, y, job_id, config } = req.pathParameters
key = `tile/${job_id}/${config}/${z}/${x}/${y}`
/* eslint-enable camelcase */
} else if (key.startsWith('/')) {
// API Gateway request.path object starts with a leading slash,
// which would cause the uploaded object to have the wrong prefix.
key = key.slice(1)
}

const upload = new aws.S3().putObject({
Expand Down

0 comments on commit 6282f7a

Please sign in to comment.