Skip to content

Commit

Permalink
fix(routes): make behaviors additive, do not replace
Browse files Browse the repository at this point in the history
  • Loading branch information
ividito committed Feb 23, 2024
1 parent 252253f commit d646604
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions routes/infrastructure/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,37 @@ def __init__(
certificate=domain_cert,
domain_names=[f"{stage}.{veda_route_settings.domain_hosted_zone_name}"]
if veda_route_settings.domain_hosted_zone_name
else None,
additional_behaviors={
"/api/stac*": cf.BehaviorOptions(
origin=origins.HttpOrigin(
f"{stac_api_id}.execute-api.{region}.amazonaws.com",
origin_id="stac-api",
),
cache_policy=cf.CachePolicy.CACHING_DISABLED,
allowed_methods=cf.AllowedMethods.ALLOW_ALL,
origin_request_policy=cf.OriginRequestPolicy.ALL_VIEWER_EXCEPT_HOST_HEADER,
),
"/api/raster*": cf.BehaviorOptions(
origin=origins.HttpOrigin(
f"{raster_api_id}.execute-api.{region}.amazonaws.com",
origin_id="raster-api",
),
cache_policy=cf.CachePolicy.CACHING_DISABLED,
allowed_methods=cf.AllowedMethods.ALLOW_ALL,
origin_request_policy=cf.OriginRequestPolicy.ALL_VIEWER_EXCEPT_HOST_HEADER,
),
},
else None
)

if veda_route_settings.cloudfront:
self.distribution.add_behavior(
{
"/api/stac*": cf.BehaviorOptions(
origin=origins.HttpOrigin(
f"{stac_api_id}.execute-api.{region}.amazonaws.com",
origin_id="stac-api",
),
cache_policy=cf.CachePolicy.CACHING_DISABLED,
allowed_methods=cf.AllowedMethods.ALLOW_ALL,
origin_request_policy=cf.OriginRequestPolicy.ALL_VIEWER_EXCEPT_HOST_HEADER,
)
}
)
self.distribution.add_behavior(
{
"/api/raster*": cf.BehaviorOptions(
origin=origins.HttpOrigin(
f"{raster_api_id}.execute-api.{region}.amazonaws.com",
origin_id="raster-api",
),
cache_policy=cf.CachePolicy.CACHING_DISABLED,
allowed_methods=cf.AllowedMethods.ALLOW_ALL,
origin_request_policy=cf.OriginRequestPolicy.ALL_VIEWER_EXCEPT_HOST_HEADER,
)
}
)

self.hosted_zone = aws_route53.HostedZone.from_hosted_zone_attributes(
self,
"hosted-zone",
Expand Down

0 comments on commit d646604

Please sign in to comment.