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

Add API Gateway Local setup #200

Merged
merged 3 commits into from
Dec 31, 2024
Merged

Add API Gateway Local setup #200

merged 3 commits into from
Dec 31, 2024

Conversation

rustworthy
Copy link
Contributor

Addresses #196

image

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

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

This is excellent, thank you!

CONTRIBUTING.md Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

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

It'd be nice if we could somehow avoid the duplication between this and

resource "aws_apigatewayv2_route" "api_event_post" {
api_id = aws_apigatewayv2_api.www.id
route_key = "POST /api/event"
target = "integrations/${aws_apigatewayv2_integration.www.id}"
}
resource "aws_apigatewayv2_route" "api_event_eid_post" {
api_id = aws_apigatewayv2_api.www.id
route_key = "POST /api/event/{eid}"
target = "integrations/${aws_apigatewayv2_integration.www.id}"
}
resource "aws_apigatewayv2_route" "api_event_eid_get" {
api_id = aws_apigatewayv2_api.www.id
route_key = "GET /api/event/{eid}"
target = "integrations/${aws_apigatewayv2_integration.www.id}"
}
resource "aws_apigatewayv2_route" "api_route" {
for_each = {
get_eeq = "GET /api/event/{eid}/questions",
get_eeqs = "GET /api/event/{eid}/questions/{secret}",
post_toggle = "POST /api/event/{eid}/questions/{secret}/{qid}/toggle/{property}",
get_q = "GET /api/questions/{qids}",
post_vote = "POST /api/vote/{qid}/{updown}",
}
api_id = aws_apigatewayv2_api.www.id
route_key = each.value
target = "integrations/${aws_apigatewayv2_integration.www.id}"
}
, but I don't know if there's an easy way to do that? I suppose we could do the terraform configuration somehow with SAM as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You think we could open an issue for that so that if the number of endpoints grows and we feel burden, we can optimize this.

I am actually always using the axum app without lambda layer plus DynamoDB Local when testing stuff end-to-end locally. It just works as you point out here

I can see though how having API Gateway Local setup might be useful - we can check that the mapping really works and that the request reaches axum app as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and also I really love how things a described and organized in infra with Terraform

Copy link
Owner

Choose a reason for hiding this comment

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

Yep, opening a ticket to do that as a follow-up seems reasonable to me!

Honestly, the other path we could take is to just have a custom check in CI that the two match up.

@rustworthy rustworthy requested a review from jonhoo December 31, 2024 10:58
@jonhoo
Copy link
Owner

jonhoo commented Dec 31, 2024

The next question now is: can we get CI to also run (and succeed with) cargo test --release?

@jonhoo jonhoo merged commit 2b4a41c into jonhoo:main Dec 31, 2024
7 checks passed
@rustworthy
Copy link
Contributor Author

This is excellent, thank you!

it is my pleasure, as for this thread, since we are talking to the Backend directly in the test rather via a server, the test binary compiles and succeeds in release mode right now:

image

So we just need to add the flag on the CI, I will open a chaser.

But I think what you mean here, is more about how do we test the lambda-power app (i.e. the LambdaLayer'ed app in release mode). I think this implies launching lambda_http::run(app).await? in the tests, building cooresponding API Gateway events for each route, acting and making the assertions.

The ultimate test though would imply launching the wewerewondering client and the server in release mode behind API Gateway Local (and talking to DynamoDB Local), then acting on the client side and making some assertions (we already got this thread)

@jonhoo
Copy link
Owner

jonhoo commented Jan 1, 2025

A bit of all of the above. I'm arguably mixing up a bunch of different thoughts here, so let me put them in a new issue. Give me a sec.

@jonhoo
Copy link
Owner

jonhoo commented Jan 1, 2025

#202

@rustworthy
Copy link
Contributor Author

#202

Sounds like a plan.

I remember I touched (or rather pulled?) fantoccini previously for a leptos-powered app testing.

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.

2 participants