DevOps Engineer, Software Architect and Software Developering

Sharing of much content of DevOps Engineer, Software Architect or Software Developer to teach more people to bee better specialist in the field. Primary focus are DevOps

Member-only story

How you can test your AWS cloud infrastructure locally with Pytest and LocalStack inside a Docker containers

Image from LocalStack documentation

If you did not know too much about what LocalStack is, it's a way you almost can test AWS services locally before your deploy your code, and its support running inside a Docker container so you can use it inside your CI/CD pipeline, if you want to read the basic about LocalStack you can read my article Test your Amazon Web Service (AWS) services locally before deploying them into the cloud and waste money with LocalStack — AWS where you will learn how to get up and running with LocalStack.

You can expect to learn about how to use LocalStack inside your CI/CD pipeline when you need to test AWS services from Pytest and how you can link 2 Docker containers together in the same network to communicate better, and we will build some AWS CDK code to deploy our stack for testing, all the code will not we in this article, it can be found on my GitHub in the following repository.

Creating the test stack with a Lambda function and a Lambda layer

We want to test a Lambda function, and we know we are using layers inside, that's why our Stack should deploy our Lambda function and our Lambda layer when we are deploying our AWS CDK code.

When you are working with layers, it can be necessary to create a symlink in your project so your code editor knows the links between, if you do that be careful to use the following symlink in your Lambda function, you should execute your symlink folder before your deploy the code.

line 18: Start preparing our Lambda Layer
line 21: Using from assets function, it works if you have the Python packages locally inside your project, if you are using a…

--

--

DevOps Engineer, Software Architect and Software Developering
DevOps Engineer, Software Architect and Software Developering

Published in DevOps Engineer, Software Architect and Software Developering

Sharing of much content of DevOps Engineer, Software Architect or Software Developer to teach more people to bee better specialist in the field. Primary focus are DevOps

Paris Nakita Kejser
Paris Nakita Kejser

Written by Paris Nakita Kejser

DevOps Engineer, Software Architect, Software Developer, Data Scientist and identify me as a non-binary person.

No responses yet