Recently, just put all staff done to create a fundamental work to migrate the existing system to aws beanstalk. The main reason to use beanstalk is because that the current system used spring+java. Beanstalk will be make it easy to handle the serverless environment to save the company cost.
1. Write the basic spring boot rest application, I created 2 controller, one for authenticate to fetch te token and one DemoController to support general resource request using Bearer Token of Cognito.
DemoController:
2.Configure to set the public access to /auth and secured access to /demo The SecurityConfig.java above also defined the JWTAuthenticateEntryPoint to handle the validation error case and JwtAuthenticationFilter to do the validation based on cognito Bearer token.
JWTAuthenticateEntryPoint:
JwtAuthenticationFilter:
The line 18 set the credential back to requestContext as the global context which is used by DemoController above.
3. Start the spring boot server, and run the test, assuming you had done for your CognitoServic implementation.
For life easy purpose, I use port 5000 since Elastic Beanstalks use 5000 as the default port for mapping.
4. follow up aws official doc to upload the jar you built with gradle, if you compile with JDK 11 and make sure to use corretto 11 Evn during the configuration(very important). Also to enable Load balancer to scalability purpose for real production usage.
5. After that we should be all set to run now.
1. Write the basic spring boot rest application, I created 2 controller, one for authenticate to fetch te token and one DemoController to support general resource request using Bearer Token of Cognito.
DemoController:
2.Configure to set the public access to /auth and secured access to /demo The SecurityConfig.java above also defined the JWTAuthenticateEntryPoint to handle the validation error case and JwtAuthenticationFilter to do the validation based on cognito Bearer token.
JWTAuthenticateEntryPoint:
JwtAuthenticationFilter:
The line 18 set the credential back to requestContext as the global context which is used by DemoController above.
3. Start the spring boot server, and run the test, assuming you had done for your CognitoServic implementation.
For life easy purpose, I use port 5000 since Elastic Beanstalks use 5000 as the default port for mapping.
4. follow up aws official doc to upload the jar you built with gradle, if you compile with JDK 11 and make sure to use corretto 11 Evn during the configuration(very important). Also to enable Load balancer to scalability purpose for real production usage.
5. After that we should be all set to run now.
Comments
Post a Comment