Dynamic inventory inside a playbook example

Hi,
I am currently working on using dynamic inventory for configuring ec2 instances on AWS environment. I would appreciate if someone can give an example of how ec2.py can be used inside a playbook to provide dynamic inventory information to other plays in the same playbook or to other playbooks using the include statement.

Thank you