# Configuring AWS EC2 instance after it's created through Ansible

**URL:** <https://forum.ansible.com/t/configuring-aws-ec2-instance-after-its-created-through-ansible/22392>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [August 26, 2016, 2:16am UTC](https://forum.ansible.com/t/configuring-aws-ec2-instance-after-its-created-through-ansible/22392 "2016-08-26T02:16:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Ludvig](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@Michael\_Ludvig](https://forum.ansible.com/u/Michael_Ludvig)\
**Post date:** [August 26, 2016, 2:16am UTC](https://forum.ansible.com/t/configuring-aws-ec2-instance-after-its-created-through-ansible/22392/1 "2016-08-26T02:16:29Z")

</div>

Hi there

I’ve got a play that creates an AWS EC2 instance through a CloudFormation template. After it’s created I would like to configure it - I can use the AWS tools to do that but I prefer to use Ansible to be consistent with our other deployments.

What I have now is:

`

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [August 30, 2016, 1:03am UTC](https://forum.ansible.com/t/configuring-aws-ec2-instance-after-its-created-through-ansible/22392/2 "2016-08-30T01:03:35Z")

</div>

You can use the returned data from cloudformation to call [add\_host](http://docs.ansible.com/ansible/add_host_module.html), then start a new play that targets that host, or set up an EC2 dynamic inventory script that will pick up the host(s) you’re creating and conditionally call meta: inventory\_refresh when you know an instance got created (then do the same thing: start another play that touches the right host(s)). I personally prefer the add\_host approach as it’s more definitive that you’re touching exactly the right host, but potato, potahto…

-Matt
