using ansible on aws, then get the IP address of the aws instances.

I have an ansible playbook that starts up some aws instances. once they are up I can see the instances have
public ip and private ip.

is there a way I can programmatically get the ip addresses from outside aws cliud instead of of having to look at the aws console ?

I want my application (teamcity, run on linux) outside of aws to call the ansible playbook, start up the instances, then when
they are up I need a way to go get the ip addresses of the instances that have been brought up in aws.

has anyone done anything like this ?

It depends on how you want to approach this.

1st approach: You can use the ec2.py inventory generator.
2nd approach: You can write Ansible Filters to get inventory dynamically during the same playbook run. Here is an example of Filter that I have written for AWS.