Skip to content
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

Added caching URLs #1818

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ jobs:
# MAP_ICONS_SHADOW_SIZE: ${{ vars.MAP_ICONS_SHADOW_SIZE }}
# MAP_ICONS_TOOLTIP_OFFSET: ${{ vars.MAP_ICONS_TOOLTIP_OFFSET }}
MORE_INFORMATION_LINK: ${{ vars.MORE_INFORMATION_LINK }}
OPENMAPS_BASE_URL: ${{ vars.OPENMAPS_BASE_URL }}
OPENMAPS_BASE_URL: https://maps.${{ vars.TARGET_ENV }}.bcwildfireservices.com
SERVICES6_BASE_URL: https://services6.${{ vars.TARGET_ENV }}.bcwildfireservices.com
POINT_ID_URL: ${{ vars.POINT_ID_URL }}
PROJECT_VERSION: ${{ steps.version.outputs.info }}
REPORT_A_WILDFIRE_PHONE_LINE: ${{ vars.REPORT_A_WILDFIRE_PHONE_LINE }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ jobs:
# MAP_ICONS_SHADOW_SIZE: ${{ vars.MAP_ICONS_SHADOW_SIZE }}
# MAP_ICONS_TOOLTIP_OFFSET: ${{ vars.MAP_ICONS_TOOLTIP_OFFSET }}
MORE_INFORMATION_LINK: ${{ vars.MORE_INFORMATION_LINK }}
OPENMAPS_BASE_URL: ${{ vars.OPENMAPS_BASE_URL }}
OPENMAPS_BASE_URL: https://maps.${{ vars.TARGET_ENV }}.bcwildfireservices.com
SERVICES6_BASE_URL: ${{ vars.SERVICES6_BASE_URL }}
POINT_ID_URL: ${{ vars.POINT_ID_URL }}
PROJECT_VERSION: ${{ steps.version.outputs.info }}
REPORT_A_WILDFIRE_PHONE_LINE: ${{ vars.REPORT_A_WILDFIRE_PHONE_LINE }}
Expand Down
248 changes: 124 additions & 124 deletions load-testing/WFNEWS_Load_Test.jmx

Large diffs are not rendered by default.

248 changes: 124 additions & 124 deletions load-testing/WFNEWS_Load_Test_2.jmx

Large diffs are not rendered by default.

248 changes: 124 additions & 124 deletions load-testing/WFNEWS_Load_Test_2_Cloudfront.jmx

Large diffs are not rendered by default.

222 changes: 111 additions & 111 deletions load-testing/WFNEWS_Load_Test_2_No_Cloudfront.jmx

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions terraform/cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,144 @@ resource "aws_cloudfront_distribution" "wfnews_redirect_receiver" {
}
}

resource "aws_cloudfront_distribution" "wfnews_openmaps_cache" {
#NOTE: This points at the government openmaps service

count = var.cloudfront ? 1 : 0

aliases = ["maps.${var.target_env}.bcwildfireservices.com"]

origin {
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "https-only"
origin_ssl_protocols = [
"TLSv1.2"
]
}

domain_name = var.target_env == "prod" ? "openmaps.gov.bc.ca" : "test.openmaps.gov.bc.ca"
origin_id = "wfnews_openmaps_cache_${var.target_env}"

}

enabled = true
is_ipv6_enabled = true

default_cache_behavior {
allowed_methods = [
"GET",
"HEAD",
"OPTIONS"
]
cached_methods = ["GET", "HEAD"]

target_origin_id = "wfnews_openmaps_cache_${var.target_env}"

forwarded_values {
query_string = true
headers = ["Origin", "Authorization"]

cookies {
forward = "all"
}
}

response_headers_policy_id = aws_cloudfront_response_headers_policy.cache_control_reponse_headers.id

viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 300
max_ttl = 300
}

price_class = "PriceClass_100"

restrictions {
geo_restriction {
restriction_type = var.target_env == "prod" ? "none" : "whitelist"
locations = var.target_env == "prod" ? [] : ["CA", "US", "AR"]
}
}

tags = local.common_tags

viewer_certificate {
acm_certificate_arn = var.certificate_arn
ssl_support_method = "sni-only"
}
}

resource "aws_cloudfront_distribution" "wfnews_services6_cache" {
#NOTE: This points at the government openmaps service

count = var.cloudfront ? 1 : 0

aliases = ["maps.${var.target_env}.bcwildfireservices.com"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here


origin {
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "https-only"
origin_ssl_protocols = [
"TLSv1.2"
]
}

domain_name = "services6.arcgis.com"
origin_id = "wfnews_services6_cache_${var.target_env}"

}

enabled = true
is_ipv6_enabled = true

default_cache_behavior {
allowed_methods = [
"GET",
"HEAD",
"OPTIONS"
]
cached_methods = ["GET", "HEAD"]

target_origin_id = "wfnews_services6_cache_${var.target_env}"

forwarded_values {
query_string = true
headers = ["Origin", "Authorization"]

cookies {
forward = "all"
}
}

response_headers_policy_id = aws_cloudfront_response_headers_policy.cache_control_reponse_headers.id

viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 300
max_ttl = 300
}

price_class = "PriceClass_100"

restrictions {
geo_restriction {
restriction_type = var.target_env == "prod" ? "none" : "whitelist"
locations = var.target_env == "prod" ? [] : ["CA", "US", "AR"]
}
}

tags = local.common_tags

viewer_certificate {
acm_certificate_arn = var.certificate_arn
ssl_support_method = "sni-only"
}
}

output "wfnews_cloudfront_client_url" {
value = "https://${aws_cloudfront_distribution.wfnews_geofencing_client[0].domain_name}"
}
Expand Down
28 changes: 28 additions & 0 deletions terraform/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,31 @@ resource "aws_route53_record" "wfone-notifications-api" {
evaluate_target_health = true
}
}

resource "aws_route53_record" "wfnews_openmaps_cache" {
//We will eventually phase out old URLs, but use them for now
//count = var.target_env == "prod" ? 0 : 1

zone_id = data.aws_route53_zone.zone.id
name = "maps.${var.target_env}.bcwildfireservices.com"
type = "A"
alias {
name = aws_cloudfront_distribution.wfnews_openmaps_cache[0].domain_name
zone_id = aws_cloudfront_distribution.wfnews_openmaps_cache[0].hosted_zone_id
evaluate_target_health = true
}
}

resource "aws_route53_record" "wfnews_services6_cache" {
//We will eventually phase out old URLs, but use them for now
//count = var.target_env == "prod" ? 0 : 1

zone_id = data.aws_route53_zone.zone.id
name = "services6.${var.target_env}.bcwildfireservices.com"
type = "A"
alias {
name = aws_cloudfront_distribution.wfnews_services6_cache[0].domain_name
zone_id = aws_cloudfront_distribution.wfnews_services6_cache[0].hosted_zone_id
evaluate_target_health = true
}
}
6 changes: 5 additions & 1 deletion terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,11 @@ resource "aws_ecs_task_definition" "wfnews_client" {
},
{
name = "OPENMAPS_BASE_URL",
value = var.openmapsBaseUrl
value = "https://${aws_route53_record.wfnews_openmaps_cache.name}"
},
{
name = "SERVICES6_BASE_URL",
value = "https://${aws_route53_record.wfnews_services6_cache.name}"
},
{
name = "SITEMINDER_URL_PREFIX",
Expand Down
2 changes: 1 addition & 1 deletion terraform/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ resource "aws_lambda_function" "wfnews-cache-invalidator" {
variables = {
S3_BUCKET = aws_s3_bucket.wfnews-monitor-queue-bucket.id
SECRET_NAME = var.SECRET_NAME
DISTRIBUTION_IDS = var.MAPS_CLOUDFRONT_DISTRIBUTION_IDS
DISTRIBUTION_IDS = "${aws_cloudfront_distribution.wfnews_openmaps_cache.id},${aws_cloudfront_distribution.wfnews_services6_cache.id}"
}
}
vpc_config {
Expand Down
Loading