Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SpringIO_19-05-2023.pdf

 SpringIO_19-05-2023.pdf

Github repo: https://github.com/localstack/shipment-list-demo

You run your Spring Boot application on AWS for production. But where do you test it? Probably on AWS as well; however, there are good reasons for reconsidering: development speed and cost. Let’s see how you can do that with the help of LocalStack.

Let’s say you run your Spring Boot application on AWS and provision the infrastructure with Terraform, which is almost the default by now. You can switch it to run for development and testing to a local installation in three easy steps:

-configure your dev environment variables
-start LocalStack on Docker
-run your IaC (infrastructure as code) configuration files

Allow me to elaborate: in this presentation, we leverage one of the core features of the Spring framework that allows us to bind our beans to different profiles and configure our environments. This also gives you the opportunity to test your IaC and make sure it’s consistent across all environments. While production will continue to run on AWS resources, dev will use high-fidelity emulations that run directly on your machine. Our application preserves the behavior we see on AWS. That means faster and cheaper dependencies.

Anca Ghenade

May 19, 2023
Tweet

More Decks by Anca Ghenade

Other Decks in Programming

Transcript

  1. 2. Developing on a local machine, they soon find out

    that there are lots of dependencies with resources in the cloud
  2. 3. They realize that the dev & test loop is

    extremely slow and tedious. Every local change needs to be packaged and uploaded to the cloud for testing.
  3. 4. Now the Software Ninja has a red build on

    their feature branch, but can’t efficiently test and debug their code in the CI/CD pipeline.
  4. 5. The whole team is using Git flow for development

    - one CI build per feature branch. There is an explosion of different environments required for development (branches x developers).
  5. 6. The Ninja manager approaches the team and complains that

    AWS dev/test resources are not being cleaned up properly causing cost spikes.
  6. How much of your system you can test Cloud emulation

    Full cloud emulation with service integration 3 Staging environments Highest fidelity because it actually runs in the cloud 4 Mocking Mock out cloud APIs 1 Service emulation Replace individual services with local versions 2 Testability of Cloud App Deployments
  7. Additional pain points: You’re working in environments that have concerns

    about: • Security • Regulatory compliance • Data Sovereignty • Risk Management * We’re talking about banking and healthcare especially here.
  8. How is LocalStack? • Enables a highly efficient dev &

    test loop for cloud apps • Ships as a Docker image, easy to install and start up • Support for 90-ish services (and growing): ◦ compute (Lambda, ECS, EKS) ◦ various databases (DynamoDB, RDS) ◦ messaging (SQS, Kinesis, MSK) ◦ some sophisticated/exotic APIs (Athena, Glue) • CI integrations & advanced collaboration features ◦ redefining the way cloud apps are developed across the lifecycle!
  9. Business Logic: • Shipment entities • A shipment has one

    sender and one receiver • Each participant has an address • The shipment has weight defined (for ship/plane calculations) • We need to add the size as a picture • For size we’re using the IIS (Internet International System) “Banana for scale” Github repo: https://github.com/localstack/shipment-list-demo
  10. Quick recap • Bean configuration - using Java @Configuration classes

    • Java AWS SDK - helps interaction with resources • Spring Profiles - environment specific configuration • IaC via Terraform - consistency across environments
  11. Because of reasons: • Most applications are complex in used

    resources • Creating resources is time consuming • Development cycles can be slow - costs developer time • Resources are tedious to clean up • If not disposed of properly, resources can be costly • Interaction between services can be slow on AWS
  12. AWS Parity • AWS Server Framework ◦ weekly runs to

    check parity ◦ makes heavy use of botocore • Snapshot testing • Metrics collection to track test coverage