Skip to content

Commit

Permalink
fix: update root_path to set default, update origin naming to match b…
Browse files Browse the repository at this point in the history
…ackend convention
  • Loading branch information
Jennifer Tran committed Jun 17, 2024
1 parent ff2c538 commit 2146489
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion infrastructure/cf_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DISTRIBUTION_CONFIG=$(jq '.DistributionConfig' current-config.json)
# Add a new origin for the workflows API
MODIFIED_CONFIG=$(echo $DISTRIBUTION_CONFIG | jq --arg origin_id "$WORKFLOWS_API_ORIGIN_ID" --arg domain_name "$WORKFLOWS_API_DOMAIN_NAME" '.Origins.Items += [{"Id": $origin_id, "DomainName": $domain_name, "CustomOriginConfig": {"HTTPPort": 80, "HTTPSPort": 443, "OriginProtocolPolicy": "https-only", "OriginSslProtocols": {"Items": ["TLSv1.2"], "Quantity": 1}, "OriginReadTimeout": 30, "OriginKeepaliveTimeout": 5}, "OriginPath": "", "CustomHeaders": {"Quantity": 0}}] | .Origins.Quantity += 1')
# Add a new cache behavior for the workflows API
MODIFIED_CONFIG=$(echo $MODIFIED_CONFIG | jq --arg origin_id "$WORKFLOWS_API_ORIGIN_ID" '.CacheBehaviors.Items += [{"PathPattern": "/api/workflows/*", "TargetOriginId": $origin_id, "ViewerProtocolPolicy": "redirect-to-https", "AllowedMethods": {"Items": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"], "Quantity": 7, "CachedMethods": {"Items": ["GET", "HEAD"], "Quantity": 2}}, "SmoothStreaming": false, "CachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", "LambdaFunctionAssociations": {"Quantity": 0},"FunctionAssociations": {"Quantity": 0}, "FieldLevelEncryptionId": "", "Compress": true}] | .CacheBehaviors.Quantity += 1')
MODIFIED_CONFIG=$(echo $MODIFIED_CONFIG | jq --arg origin_id "$WORKFLOWS_API_ORIGIN_ID" '.CacheBehaviors.Items += [{"PathPattern": "/api/workflows*", "TargetOriginId": $origin_id, "ViewerProtocolPolicy": "redirect-to-https", "AllowedMethods": {"Items": ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"], "Quantity": 7, "CachedMethods": {"Items": ["GET", "HEAD"], "Quantity": 2}}, "SmoothStreaming": false, "CachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad", "LambdaFunctionAssociations": {"Quantity": 0},"FunctionAssociations": {"Quantity": 0}, "FieldLevelEncryptionId": "", "Compress": true}] | .CacheBehaviors.Quantity += 1')

# Step 3: Update the CloudFront distribution with the modified configuration
echo $MODIFIED_CONFIG | jq . > modified-config.json
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ resource "null_resource" "update_cloudfront" {
count = coalesce(var.cloudfront_id, false) != false ? 1 : 0

provisioner "local-exec" {
command = "${path.module}/cf_update.sh ${var.cloudfront_id} workflows_api_origin \"${aws_apigatewayv2_api.workflows_http_api.api_endpoint}\""
command = "${path.module}/cf_update.sh ${var.cloudfront_id} workflows-api \"${aws_apigatewayv2_api.workflows_http_api.api_endpoint}\""
}

depends_on = [aws_apigatewayv2_api.workflows_http_api]
Expand Down
2 changes: 1 addition & 1 deletion workflows_api/runtime/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Settings(BaseSettings):
description="The Cognito APP Secret that contains cognito creds"
)
stage: str = Field(description="API stage")
workflow_root_path: str = Field(description="Root path of API")
workflow_root_path: str = Field("/api/workflows", description="Root path of API")
ingest_url: str = Field(description="URL of ingest API")
raster_url: str = Field(description="URL of raster API")
stac_url: str = Field(description="URL of STAC API")
Expand Down

0 comments on commit 2146489

Please sign in to comment.