skip to Main Content

I need to check in terraform if a floating ip resource with a specific ip address has been yet allocated. I’ve tryed to use terraform datasources to do it but the problem is that when the resource is not found an exception is thrown and the azure pipeline stop working.

Is there a way to do that check catching the error or using another approach?
Thanks in advance.

N.

Note: terraform is calling openstack api to work with the infrastructure (ibm icic)

2

Answers


  1. No, there is no such way from terraform, as TF does not provide tools to conditionally check if a resource exist or not. You have to check it outside of TF by developing some script for that, for example in python, and then passing the outcome of the script (true, false) as an input argument to TF.

    Login or Signup to reply.
  2. Terraform does not have such a construct… But.

    Here’s a trick (untested, you’ll let me know) that may save the day:

    LMK how that goes?!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search