# Idempotent creation of AWS RDS ?

**URL:** <https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [November 25, 2013, 9:07pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998 "2013-11-25T21:07:41Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Shenton](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@Chris\_Shenton](https://forum.ansible.com/u/Chris_Shenton)\
**Post date:** [November 25, 2013, 9:07pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/1 "2013-11-25T21:07:41Z")

</div>

I can create an AWS EC2 instance with the ‘ec2’ module and a unique ‘id’, and Ansible skips creation if an instance with this name already exists. This feature doesn’t seem to exist in the ‘rds’ module.

Any suggestions how to check for existence of an RDS and only create if it doesn’t exist?

Thanks.

---

<div class="post-metadata">

**Author:** ![Erik\_Anderson](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@Erik\_Anderson](https://forum.ansible.com/u/Erik_Anderson)\
**Post date:** [November 25, 2013, 9:09pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/2 "2013-11-25T21:09:58Z")

</div>

You probably ought to look into using AWS Cloudformation for AWS resource  
creation - Ansible has support for it, and it handles things like this very  
well.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 25, 2013, 9:16pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/3 "2013-11-25T21:16:35Z")

</div>

I believe you missed my memo on “the world says idempotent too much” 🙂

Can you share what happens when you run it again, showing “-v” from the ansible-playbook run?

---

<div class="post-metadata">

**Author:** ![Bruce\_Pennypacker](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Bruce\_Pennypacker](https://forum.ansible.com/u/Bruce_Pennypacker)\
**Post date:** [November 25, 2013, 9:18pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/4 "2013-11-25T21:18:03Z")

</div>

For the time being you can use command=facts to see if it already exists and only use command=create if it doesn’t.

-Bruce

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 25, 2013, 9:19pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/5 "2013-11-25T21:19:34Z")

</div>

BTW, if this is creating a second, please file a bug.

+5 ansible points for not saying “idempotent” in the ticket 🙂

---

<div class="post-metadata">

**Author:** ![Peter\_Gehres](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@Peter\_Gehres](https://forum.ansible.com/u/Peter_Gehres)\
**Post date:** [November 25, 2013, 9:20pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/6 "2013-11-25T21:20:19Z")

</div>

Does Github have an idempotent API for creating tickets?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 25, 2013, 9:24pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/7 "2013-11-25T21:24:07Z")

</div>

Fuzzy ticket matching might be lucrative.

---

<div class="post-metadata">

**Author:** ![Chris\_Shenton](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@Chris\_Shenton](https://forum.ansible.com/u/Chris_Shenton)\
**Post date:** [November 25, 2013, 10:42pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/8 "2013-11-25T22:42:32Z")

</div>

Ah, that ‘facts’ command should work.

Without a check like this, it will detect the existing instance and fail with:

msg: DB Instance already exists

@Michael, yeah, I just started catching up on the group and then read The Memo 🙂

Thanks, all.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 26, 2013, 12:57am UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/9 "2013-11-26T00:57:54Z")

</div>

I’d rather have the RDS module upgraded.

CloudFormation requires writing some messy JSON, where as Ansible is a lot more friendly when using modules directly.

I agree some others may disagree.

---

<div class="post-metadata">

**Author:** ![Erik\_Anderson](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@Erik\_Anderson](https://forum.ansible.com/u/Erik_Anderson)\
**Post date:** [November 26, 2013, 1:03am UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/10 "2013-11-26T01:03:22Z")

</div>

If all you're doing is creating an RDS instance, then yes, absolutely CFN  
isn't ideal.

---

<div class="post-metadata">

**Author:** ![Bruce\_Pennypacker](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Bruce\_Pennypacker](https://forum.ansible.com/u/Bruce_Pennypacker)\
**Post date:** [November 26, 2013, 2:31pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/11 "2013-11-26T14:31:33Z")

</div>

I’d be more than happy to improve the rds module. The question I have is what’s the best approach to take. The problem, as I see it, is that the rds interface is rather complex, so trying to distill it down for Ansible has the potential to be rather tricky. There are a number of both required and optional parameters when you create a database. What should the module do, for example, if you try to create a database with the same name but vastly different parameters?

When you create a database you need to specify the name, type of database (oracle, mysql, etc), the disk size for the data store, the cpu/memory size of the server, and the root username/password. Suppose you already have an oracle database named “foo” and you then call the rds module to create a mysql database named “foo”. I would argue that this should generate an error of some sort and not simply return changed=false since the underlying database is vastly different than what you requested. But what about something like disk size? Should it trigger an error if you try to create a database where all the parameters are identical to an existing instance but the size is off by a gigabyte? And then there are all the optional parameters like backup\_window. If you don’t specify a backup window then Amazon will randomly assign one, so should any ‘changed’ check simply ignore parameters like these?

Similar issues arise with regards to the ‘modify’ command since there are different ways it can be applied. If you tell AWS to increase the size of your database you can tell it to apply the change immediately or you can defer that change until the instances next maintenance window, at which point it will reboot & resize the database automatically. How should cases be handled where there are conflicting modifications requested? Suppose you issue a command to resize your database to 200 gig during the next maintenance window, then before that maintenance window you run a play that tries to resize it to 250 gig immediately? I’m not sure if the AWS API even supports modifying/deleting pending events. I just did a quick check of boto and it doesn’t seem to have that capability.

-Bruce

---

<div class="post-metadata">

**Author:** ![Matt\_Jaynes](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Matt\_Jaynes](https://forum.ansible.com/u/Matt_Jaynes)\
**Post date:** [November 27, 2013, 6:58pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/12 "2013-11-27T18:58:10Z")

</div>

Been googling around for the idempotent memo you mentioned - anyone have a link? (or maybe it was a joke and I’m a little clueless?) 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 27, 2013, 7:07pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/13 "2013-11-27T19:07:36Z")

</div>

Ah, here: [https://groups.google.com/forum/#!msg/Ansible-project/WpRblldA2PQ/lYDpFjBXDlsJ](https://groups.google.com/forum/#!msg/Ansible-project/WpRblldA2PQ/lYDpFjBXDlsJ)

I should have totally added another paragraph on “imperative” and “declarative” 🙂

---

<div class="post-metadata">

**Author:** ![C\_Morgan\_Hamill](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@C\_Morgan\_Hamill](https://forum.ansible.com/u/C_Morgan_Hamill)\
**Post date:** [November 27, 2013, 7:09pm UTC](https://forum.ansible.com/t/idempotent-creation-of-aws-rds/13998/14 "2013-11-27T19:09:57Z")

</div>

Excerpts from Matt Jaynes's message of 2013-11-27 13:58:10 -0500:

> Been googling around for the idempotent memo you mentioned - anyone have a  
> link? (or maybe it was a joke and I'm a little clueless?) 🙂

See, it's clear that this mailing list is not nearly idempotent enough!  
It should be obvious that the mailing lists can be modeled as  
a surjection from the set of senders to the set of mailing lists.

We should rewrite it in node.js to make sure it's web scale. Then we'll  
be able to make sure our NoSQL databases are cloud-ready.
