# best practice for linking/attachment of cloud resources

**URL:** <https://forum.ansible.com/t/best-practice-for-linking-attachment-of-cloud-resources/37655>\
**Category:** Ansible Developer\
**Created:** [February 13, 2023, 3:10pm UTC](https://forum.ansible.com/t/best-practice-for-linking-attachment-of-cloud-resources/37655 "2023-02-13T15:10:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Karasek](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@Tomas\_Karasek](https://forum.ansible.com/u/Tomas_Karasek)\
**Post date:** [February 13, 2023, 3:10pm UTC](https://forum.ansible.com/t/best-practice-for-linking-attachment-of-cloud-resources/37655/1 "2023-02-13T15:10:04Z")

</div>

Hi, I’m working on a collection for a cloud infrastructure provider. I’m now thinking about how to implement assigning a “floating” IP address to a server.

I have a module for the server, and will probably have a module for the floating\_ip. I can add a field to the server (“assigned\_ips”) and pass the ID of the floating IP to it on creation and update. The construction is straightforward, but the deletion is unclear - what should happen when the assigned IP is deleted? There may be side effects to unlinking, and I foresee other issues that will become apparent later in development.

Is there a best practice for this in Ansible? I’ve looked at google.cloud and linode.cloud but haven’t really found a good use case of such linking. It almost seemed as if the authors were avoiding such functionality in the collections. I would appreciate it if someone can come up with an example module in a collection.

In Terraform, there’s clear best practice for this: there’s a special “module” ending with \_attachment (for example [0]) that manages the lifecycle of the association, in this case between device and an ip address.

Thanks for reading my question.

Best Regards,  
Tomas Karasek

[0] [https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/equinix\_metal\_ip\_attachment](https://registry.terraform.io/providers/equinix/equinix/latest/docs/resources/equinix_metal_ip_attachment)
