All of Boto3’s resource and client classes are generated at runtime. This means that you cannot directly inherit and then extend the functionality of these classes because they do not exist until the program actually starts running.
It is still possible to extend
boto3 using the events system, which allows us to run custom code when boto3 events triggered, or to provide default values. It also allows us to add additional classes to the base objects.
As an example, we can add a new class for
ec2.Instance to inherit from with a convenience method for reading tags:
This new session object can then be used normally, and whenever an
ec2.Instance is returned it will inherit our new method.