AWS Bites Podcast

89. Should you simulate AWS locally?

Welcome to the epic tale of AWS Bites! In this chapter, we embark on a perilous journey through the challenges of developing distributed applications on AWS.

We encounter fierce foes in the form of deployment times and limited access to real AWS services during local development.

But fear not, for we have powerful tools at our disposal, including the legendary LocalStack and Serverless offline. And if that's not enough, we have tips and tricks for optimizing our development flow without local simulations, using well-structured code and unit tests. We even share CloudFormation tricks to speed up deployment times and reveal the secret of speeding up the development of IAM policies with Session Policies.

So grab your swords and join us on this epic adventure to overcome the challenges of local development on AWS!

fourTheorem is the company that makes AWS Bites possible. If you are looking for a partner to accompany you on your cloud journey, check them out at fourtheorem.com!

In this episode, we mentioned the following resources:

Let's talk!

Do you agree with our opinions? Do you have interesting AWS questions you'd like us to chat about? Leave a comment on YouTube or connect with us on:

Eoin
00:08:36

I Remember the early days, trying to make a pull request on LocalStack so I could get event bridge support for some integration tests I was doing. And that was just because I was determined that it was going to work for me and I ended up spending more time on trying to work around the limitations. So this is what you're faced with. And similarly, you mentioned Step Functions local, and recently I tried to use that, but I think there was an issue with support for the new map type because they changed how you can declare maps when they added support for distributed maps, but that's not there in Step Functions local yet. So these tools will always have a challenge keeping up with the latest in the cloud. So I am more now of the opinion that you should put less effort into local simulation and more into trying to optimize your development flow in other ways. So one thing you can do without local simulations is just try and focus more on unit tests. It's a good practice anyway, but if you focus on separating your code well, then you can just unit test the logic and you don't have to deploy every time. So this is just a recommendation really around code structure, following clean code principles, separating the AWS specific stuff from the actual logic, and following some sort of pattern. Like there's plenty, especially in the serverless community, of talks and articles around hexagonal architecture, also known as ports and adapters, which is essentially a fairly simple mechanism to ensure that you separate out the inbound connections and the outbound connections and integrations into your database and other services.

00:14:39

So if they help you to speed up your local development, take that value, but be aware there might be instances where that local simulation is not going to be enough and you need to figure out another strategy. And definitely remember to structure your code in such a way that you can test most of it without having to rely on AWS. So you're definitely going to have some business logic, try to make sure that that business logic is as decoupled as possible from the logic integrating with AWS services. So you can test your own business logic without having to rely on AWS. And for all the times where you need to rely on AWS, you can also mock parts of your unit test. So there are libraries like Modo, if you do Python, that can help with that. If you use JavaScript, the new SDK also comes with an additional library that helps you to do mocking. So there are lots of ways there where just by doing unit tests, you can be so much better positioned to trust your code locally before you ship it to production. Now, we probably missed many ideas. I'm sure that people listening have lots of other ideas. Everyone is experimenting all the time with this topic. So if you have something you would like to share with us, we're definitely going to be happy to learn from you. So make sure to use the comments below or reach out to us on Twitter to share your feelings and your ideas about this topic. And as always, if you really enjoyed this episode, remember to thumbs up, subscribe, or if you're listening to the podcast only version, give us a review. Thank you very much, and we'll see you in the next episode.

Help us to make this transcription better! If you find an error, please submit a PR with your corrections.