How can I check if aws queue exists using ansible?

Viewed 52

How can I create an aws sqs queue using ansible playbook if does not alreay exist?

I do not know how to check using ansible

1 Answers

If you are checking for sqs_queue (let's say), the following code snippet might help

- hosts: localhost
  connection: local
  gather_facts: no
  tasks:
    - name: create queue if needed
      sqs_queue:
        name: "test_queue"
        state: "present"
        region: "us-east-1"

The task would create a queue if not already exists. You should see changed in the output.

If it exists then it will report ok meaning the current state already matches the required state.

You can get more information in official docs sqs queue ansible

Related