DynamoDB TestContainers in Python

Let’s get started straight away, shall we ?

Use pip to install testcontainers package

testcontainers-python library has direct support for some widely used Docker images like Selenium, MySql, Oracle, RabbitMQ etc. But they didn’t implemented any wrapper to run DyanmoDB as TestContainer. Hence I have used the Generic container to setup DynamoDB

DockerContainer class helps us create container using any Docker image

Note: Unless we specify the-sharedDb via command, DynamoDB will start with default as-inMemory.In that case, all data will be written to memory.

Refer local usage notes for more information

Connecting to DynamoDB Local Docker instance

We can pass random values to aws_access_key_id & aws_secret_access_key

Here is the complete code

Thats all folks !!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store