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

[SAM][architecture] Give up lambda for PaimonGanyuSpringBootApp, use Elastic Beanstalk instead. #10

Closed
binchoo opened this issue Jun 23, 2022 · 3 comments

Comments

@binchoo
Copy link
Owner

binchoo commented Jun 23, 2022

As-is

Running a SpringBoot application on a lambda container is not optimal at all.
The aws-serverless-java-container module is trying the best to support SpringBoot apps on the lambda service, but it is not satisfying me.

Cons:

  • DispatherServlet is not available.
  • ArgumentResolvers, ViewResolvers are not usable.
  • Cold start latency is terrible.

Pros:

  • Easy to deploy.
  • Easy to configure IAM Roles and IAM Policies.
@binchoo binchoo self-assigned this Jun 23, 2022
@binchoo binchoo added this to the release 1.0.0 milestone Jun 23, 2022
@binchoo

This comment was marked as outdated.

@binchoo binchoo changed the title [SAM][architecture] Give up lambda for PaimonGanyuSpringBootApp use ALB + EC2 instead. [SAM][architecture] Give up lambda for PaimonGanyuSpringBootApp, use ALB + EC2 instead. Jun 23, 2022
@binchoo
Copy link
Owner Author

binchoo commented Jun 23, 2022

To-be

Let's use Elastic Beanstalk.

image

@binchoo
Copy link
Owner Author

binchoo commented Jun 23, 2022

Change Impact

The principle: "Keep single-jar deployment."

Java code base

  • PaminGanyu> :application module
    • Resolve the timezone problem programmatically. (Don't make .ebextensions file. Keep the principle.)
    • Introduce a HealthCheckController to support ALB's health checking mechanisms.
    • Add a /health handler mapping.
    • application.properties> set server.port=5000 to customarily handle the proxied request from nginx.

What the doc says:
image

--HTTP(80)--> ALB --HTTP(80)--> ASG --HTTP(80)--> NGINX --HTTP(5000)--> SpringBootApp 

IAM

  • Create an IAM Role that will be required by the paimonganyu-skill's instance profile.
    • DynamoDB CRUD policies attached.
    • SSM Parameter CRUD policies attached.

AWS Beanstalk

  • Create an application named paimonganyu-skill.
  • ALB Configurations
    image
    Do not bother yourself to tell that a process is using the 5000 port, because NGINX transparently forwards requests from 80 to 5000.

AWS SAM template.yaml

  • Commentify the PaimonGanyuSpringBootApp section in the original template.yaml.
  • Write down a new template.yaml named paimonganyu-skill.yaml that configures the paimonganyu-skill application.
    • Consider multiple environments: prod and test.
  • Create an API Gateway resource explictly, as the PaimonGanyuSpringBootApp.Properties.Events is gonna be removed.
  • Create an IAM Role resource that I said before.

Makefile

  • Define a workflow that builds & deploys a bootJar to the paimonganyu-skill beanstalk app.

@binchoo binchoo changed the title [SAM][architecture] Give up lambda for PaimonGanyuSpringBootApp, use ALB + EC2 instead. [SAM][architecture] Give up lambda for PaimonGanyuSpringBootApp, use Elastic Beanstalk instead. Jun 23, 2022
binchoo added a commit that referenced this issue Jun 24, 2022
binchoo added a commit that referenced this issue Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant