Search code examples
pythonamazon-web-servicesjdbcboto3moto

How to simulate AWS services and env locally using Python moto?


Is it practically possible to simulate AWS environment locally using Moto and Python? I want to write a aws gluejob that will fetch record from my local database and will upload to S3 bucket for data quality check and later trigger a lambda function for cronjob run using Moto Library using moto.lock_glue decorator.Any suggestion or document would be highly appreciated as I don't see much clue on same.Thank you in advance.


Solution

  • AFAIK, moto is meant to patch boto modules for testing. I have experience working with LocalStack, a docker you can run locally, and it acts as a live service emulator for most AWS services (some are only available for paying users).

    https://docs.localstack.cloud/getting-started/

    You can see here which services are supported by the free version. https://docs.localstack.cloud/user-guide/aws/feature-coverage/

    in order to use it, you need to change the endpoint-url to point to the local service running on docker. As it's a docker, you can incorporate it with remote tests as well e.g., if you're using k8s or a similar orchestrator