Find a way to add extensions (e.g. callbacks) to moto
Author: retpolanneCreated Dec 15, 2023Updated Aug 28, 2026
Labelsenhancement
I have an environment where I want to test the whole EC2 creation flow, from the EC2 api request to a locally-simulated cloud VM with cloud-init.
I created this tool - https://github.com/retpolanne/cloud-vm-sim - that has an API endpoint that receives a userdata and creates a QEMU VM that can reach to this userdata and run cloud-init. I've extended the EC2 code to call this service on the mock and it works nicely :)
However, I wanted this to be cleaner - I don't want moto to have this code as this is useful just for me. I wanted to be able to specify a plugins directory and load them and call whatever is in my plugin before the EC2 response.
Source: getmoto/moto