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. Welcome to the closing keynote of Track 2!

    View Slide

  2. Develop and test your AWS-powered Spring
    Boot application locally

    View Slide

  3. [email protected]
    @tinyg210
    tinyg210
    Anca Ghenade
    DevRel Engineer @ LocalStack

    View Slide

  4. How does one go around developing applications
    using AWS services?

    View Slide

  5. 1. The Software Ninjas are tasked with developing
    a new web application on AWS Cloud

    View Slide

  6. 2. Developing on a local machine, they soon
    find out that there are lots of dependencies
    with resources in the cloud

    View Slide

  7. 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.

    View Slide

  8. 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.

    View Slide

  9. 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).

    View Slide

  10. 6. The Ninja manager approaches the team and
    complains that AWS dev/test resources are not
    being cleaned up properly causing cost spikes.

    View Slide

  11. So the developer experience sucks. 󰤆

    View Slide

  12. What about testing your AWS-powered
    applications?

    View Slide

  13. 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

    View Slide

  14. 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.

    View Slide

  15. What is LocalStack?
    A fully functional local cloud stack that was born out of these exact concerns.

    View Slide

  16. 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!

    View Slide

  17. AWS vs. LocalStack
    DEMO

    View Slide

  18. “Your application won’t even know the difference”

    View Slide

  19. View Slide

  20. 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

    View Slide

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

    View Slide

  22. View Slide

  23. 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

    View Slide

  24. Switching to LocalStack

    View Slide

  25. IaC
    Tools
    Developer
    Tools
    Language
    SDKs
    App
    Frame-
    works
    CI/CD
    Systems
    TESTCONTAINERS
    Copilot

    View Slide

  26. View Slide

  27. 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

    View Slide

  28. Some benchmarking:
    AWS LocalStack

    View Slide

  29. View Slide

  30. Testcontainers

    View Slide

  31. AWS Parity
    ● AWS Server Framework
    ○ weekly runs to check parity
    ○ makes heavy use of botocore
    ● Snapshot testing
    ● Metrics collection to track test coverage

    View Slide

  32. View Slide

  33. Thank You!
    Anca Ghenade
    May 19th,
    2023
    Barcelona

    View Slide

  34. Questions?
    Anca Ghenade
    May 19th,
    2023
    Barcelona

    View Slide

  35. [email protected]
    @tinyg210
    tinyg210
    Anca Ghenade
    DevRel Engineer @ LocalStack

    View Slide