-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure CloudFront proxy for Tilegarden #629
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
964e02e
Scaffold Tilegarden Cloudfront CDN
568ac4a
Fix CloudFront errors
6ae1364
Add deployment instructions for new Tilegarden instances
ed49193
Remove unnecessary Jest configuration in Tilegarden
101efe3
Use 'tiles' subdomain as an alias for Tilegarden CDN
271592b
Add note on order of resource creation to deployment README
8dd69b7
Bump Tilegarden timeout to 60 seconds
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
resource "aws_cloudfront_distribution" "tilegarden" { | ||
origin { | ||
custom_origin_config { | ||
http_port = 80 | ||
https_port = 443 | ||
origin_protocol_policy = "https-only" | ||
origin_ssl_protocols = ["TLSv1.2", "TLSv1.1", "TLSv1"] | ||
} | ||
|
||
domain_name = "${var.tilegarden_api_gateway_domain_name}" | ||
origin_path = "/latest" | ||
origin_id = "tilegardenOriginEastId" | ||
|
||
custom_header { | ||
name = "Accept" | ||
value = "image/png" | ||
} | ||
} | ||
|
||
aliases = ["tiles.${var.r53_public_hosted_zone}"] | ||
price_class = "${var.cloudfront_price_class}" | ||
enabled = true | ||
is_ipv6_enabled = true | ||
comment = "${var.project} (${var.environment})" | ||
|
||
default_cache_behavior { | ||
allowed_methods = ["GET", "HEAD", "OPTIONS"] | ||
cached_methods = ["GET", "HEAD"] | ||
target_origin_id = "tilegardenOriginEastId" | ||
|
||
forwarded_values { | ||
query_string = true | ||
|
||
cookies { | ||
forward = "none" | ||
} | ||
} | ||
|
||
viewer_protocol_policy = "redirect-to-https" | ||
min_ttl = 0 | ||
default_ttl = "300" # Five minutes | ||
max_ttl = "86400" # One day | ||
} | ||
|
||
restrictions { | ||
"geo_restriction" { | ||
restriction_type = "none" | ||
} | ||
} | ||
|
||
viewer_certificate { | ||
acm_certificate_arn = "${var.ssl_certificate_arn}" | ||
ssl_support_method = "sni-only" | ||
minimum_protocol_version = "TLSv1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,3 +157,9 @@ variable "aws_cloudwatch_logs_policy_arn" { | |
variable "pfb_app_alb_ingress_cidr_block" { | ||
type = "list" | ||
} | ||
|
||
# CloudFront distribution | ||
variable "tilegarden_api_gateway_domain_name" {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Claudia creates the API Gateway resource for Tilegarden separately from Terraform, we need to specify this value as an input variable. |
||
variable "cloudfront_price_class" { | ||
default = "PriceClass_100" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this interact with "it's best to finish these steps before you deploy a new stack with Terraform"? Seems like there's a bit of circularity here that would require bootstrapping, i.e. the process for creating a new stack would need to be "batch, terraform, tilegarden, terraform"? (Or would it be "batch, tilegarden, terraform, tilegarden"? Or is there actually a linear way to do it?)
Tilegarden isn't good for much without access to a database, at least not on this project. I might rephrase this to "For example, to give Tilegarden access to the database, set..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an excellent point. It's possible you could get away with doing it linearly (
Batch -> Tilegarden -> Terraform
) if you used an existing VPC, but we're not doing that here, so realistically this is implying that you'll have to doBatch -> Terraform -> Tilegarden -> Terraform
.I think we could make the setup easier if we were at least explicit about this workflow, and gave the user some guidance in doing it. My expectation is that if you were to set the
tilegarden_api_gateway_domain_name
variable to some bogus value on the first Terraform run, the resources will build properly, but the CDN won't return tiles properly; then if you adjust the variable again after setting up Tilegarden things should wire up correctly on the secondterraform apply
.I don't love this workflow, but it's the best I can think of given the constraints we're under, where the Lambda function and the CDN are interdependent but each has to be configured and managed from a separate source of truth. If you can think of a way around it, let me know!