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

feat: add load balancer and configuration for deploying cloudfront distribution #232

Closed
wants to merge 13 commits into from

Conversation

smohiudd
Copy link
Contributor

@smohiudd smohiudd commented Oct 5, 2023

To overcome the issue of the cloudfront base url not being passed to API gateway, this PR instead uses an application load balancer (which was inspired by the work done in CSDA). It also fixes the trailing slash redirect issue we were having with API gateway.

This has been deployed to the path-prefix stack and currently working at: https://delta-backend.xyz/

Some things to note:

  • the load balancer is not using a certificate so is listening over port 80 (HTTP). SSL is instead being implemented in Cloudfront. I'm not sure if this is a vulnerability.
  • I removed the stac/raster specific route 53 domain configuration
  • In order to pass the host header to the lambda, we need to implement a cloundfront cache policy in the STAC endpoint

@vincentsarago
Copy link
Contributor

vincentsarago commented Oct 5, 2023

@smohiudd I'm not sure if the issue is what I think, but when deploying API Gateway with custom domain name, I usually need update the integration in API Gateway to overwrite the hostname the FastAPI application thinks it is.

Screen Shot 2021-03-09 at 10 46 58 PM

ref developmentseed/eoapi-cdk#75

@smohiudd
Copy link
Contributor Author

smohiudd commented Oct 5, 2023

Thanks @vincentsarago, I wasn't aware of this feature in API gateway. It looks like that solves the issue that we're having. The ABL was just a test to try something similar to CSDA but if the API gateway parameter mapping is easier to implement that might be the way to go.

@slesaad
Copy link
Member

slesaad commented Oct 5, 2023

@vincentsarago 🤯 THAT WORKED! I'd been struggling with this issue for a while, thanks so much!!!!

@slesaad
Copy link
Member

slesaad commented Oct 5, 2023

@smohiudd i implemented it in ghg center, hope it helps!

stac_api_integration = aws_apigatewayv2_integrations_alpha.HttpLambdaIntegration(
            construct_id,
            handler=lambda_function,
            parameter_mapping=aws_apigatewayv2_alpha.ParameterMapping().overwrite_header(
                "host",
                aws_apigatewayv2_alpha.MappingValue.custom(veda_stac_settings.host),
            )
            if veda_stac_settings.host
            else None,
        )

@smohiudd
Copy link
Contributor Author

smohiudd commented Oct 5, 2023

@slesaad I did the same just now in my old PR! #229
It works great

@smohiudd smohiudd closed this Oct 5, 2023
@slesaad slesaad deleted the feature/alb branch July 26, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants