Repository: ansible/ansible

Issue:
aws sqs_queue fail to update delivery_delay if delivery_delay is 0
##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report


##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
- sqs_queue
##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ ansible --version
ansible 2.4.1.0
  config file = None
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible
  executable location = /home/ubuntu/pyenvansible/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"

Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).

-->
- N/A
##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
- N/A
##### SUMMARY
<!--- Explain the problem briefly -->
sqs_queue fail to set delivery_delay, if delivery_delay is 0
##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
Create a sqs queue, set delivery_delay to 1
- hosts: localhost
  connection: local

  tasks:
    - name: update sqs queues
      sqs_queue:
        name: "{{ item[0] }}"
        region: "{{ item[1] }}"
        default_visibility_timeout: 120
        message_retention_period: 345600
        maximum_message_size: 262144
        delivery_delay: '1'
        receive_message_wait_time: 0
      with_nested:
        - [ "DefaultLetterQueue" ]
        - [ "ap-northeast-1" ]

update delivery_delay to 0
- hosts: localhost
  connection: local

  tasks:
    - name: update sqs queues
      sqs_queue:
        name: "{{ item[0] }}"
        region: "{{ item[1] }}"
        default_visibility_timeout: 120
        message_retention_period: 345600
        maximum_message_size: 262144
        delivery_delay: '0'
        receive_message_wait_time: 0
      with_nested:
        - [ "DefaultLetterQueue" ]
        - [ "ap-northeast-1" ]
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
delivery_delay of DefaultLetterQueue updated to 0
##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ ansible-playbook create_test_sqs.yaml -vvvv
ansible-playbook 2.4.1.0
  config file = None
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible
  executable location = /home/ubuntu/pyenvansible/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
No config file found; using defaults
setting up inventory plugins
 [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: create_test_sqs.yaml ***************************************************************************************************************************************************
1 plays in create_test_sqs.yaml

PLAY [localhost] *****************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329 `" && echo ansible-tmp-1511159874.35-2558833681843
29="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpWSdfJc TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/se
tup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/setup.py; rm -rf "/home/ubuntu/.ansible/tmp/
ansible-tmp-1511159874.35-255883368184329/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]                                                                                                                                                          [20/2186]
META: ran handlers

TASK [update sqs queues] *********************************************************************************************************************************************************
task path: /home/ubuntu/bbmobile_ansible/create_test_sqs.yaml:7
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/cloud/amazon/sqs_queue.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609 `" && echo ansible-tmp-1511159875.0-192614452333609
="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpozP4Fh TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/sqs_queue.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/sqs_
queue.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/sqs_queue.py; rm -rf "/home/ubuntu/.ansible/t
mp/ansible-tmp-1511159875.0-192614452333609/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => (item=[u'DefaultLetterQueue', u'ap-northeast-1']) => {
    "changed": true,
    "default_visibility_timeout": "120",
    "delivery_delay": "1",
    "failed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": null,
            "aws_secret_key": null,
            "default_visibility_timeout": 120,
            "delivery_delay": 1,
            "ec2_url": null,
            "maximum_message_size": 262144,
            "message_retention_period": 345600,
            "name": "DefaultLetterQueue",
            "policy": null,
            "profile": null,
            "receive_message_wait_time": 0,
            "redrive_policy": null,
            "region": "ap-northeast-1",
            "security_token": null,
            "state": "present",
            "validate_certs": true
        }
    },
    "item": [
        "DefaultLetterQueue",
        "ap-northeast-1"
    ],
    "maximum_message_size": "262144",
    "message_retention_period": "345600",
    "name": "DefaultLetterQueue",
    "policy": null,
    "queue_arn": "arn:aws:sqs:ap-northeast-1:############:DefaultLetterQueue",
    "receive_message_wait_time": "0",
    "redrive_policy": null,
    "region": "ap-northeast-1"
}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0

Update delivery delay to 0
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ vim create_test_sqs.yaml
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ ansible-playbook create_test_sqs.yaml -vvvv
ansible-playbook 2.4.1.0
  config file = None
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible
  executable location = /home/ubuntu/pyenvansible/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
No config file found; using defaults
setting up inventory plugins
 [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: create_test_sqs.yaml ***************************************************************************************************************************************************
1 plays in create_test_sqs.yaml

PLAY [localhost] *****************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252 `" && echo ansible-tmp-1511160051.36-1839599933222
52="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpHJa6wZ TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/se
tup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/setup.py; rm -rf "/home/ubuntu/.ansible/tmp/
ansible-tmp-1511160051.36-183959993322252/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]                                                                                                                                                          [20/2281]
META: ran handlers

TASK [update sqs queues] *********************************************************************************************************************************************************
task path: /home/ubuntu/bbmobile_ansible/create_test_sqs.yaml:7
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/cloud/amazon/sqs_queue.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830 `" && echo ansible-tmp-1511160051.78-50724705419830
="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpT_1FIR TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/sqs_queue.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/sqs_
queue.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/sqs_queue.py; rm -rf "/home/ubuntu/.ansible/t
mp/ansible-tmp-1511160051.78-50724705419830/" > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=[u'DefaultLetterQueue', u'ap-northeast-1']) => {
    "changed": false,
    "default_visibility_timeout": "120",
    "delivery_delay": "1",
    "failed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": null,
            "aws_secret_key": null,
            "default_visibility_timeout": 120,
            "delivery_delay": 0,
            "ec2_url": null,
            "maximum_message_size": 262144,
            "message_retention_period": 345600,
            "name": "DefaultLetterQueue",
            "policy": null,
            "profile": null,
            "receive_message_wait_time": 0,
            "redrive_policy": null,
            "region": "ap-northeast-1",
            "security_token": null,
            "state": "present",
            "validate_certs": true
        }
    },
    "item": [
        "DefaultLetterQueue",
        "ap-northeast-1"
    ],
    "maximum_message_size": "262144",
    "message_retention_period": "345600",
    "name": "DefaultLetterQueue",
    "policy": null,
    "queue_arn": "arn:aws:sqs:ap-northeast-1:###############:DefaultLetterQueue",
    "receive_message_wait_time": "0",
    "redrive_policy": null,
    "region": "ap-northeast-1"
}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0

(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$
```

##### POSSIBLE CAUSE
```
https://github.com/ansible/ansible/blob/d8b1cb9a634d0e828a7be39d4019a6215410e643/lib/ansible/modules/cloud/amazon/sqs_queue.py
line 235 to 255
def set_queue_attribute(queue, attribute, value, check_mode=False):
    if not value:     ########if value is 0, set_queue_attribute return without update
        return False

    try:
        existing_value = queue.get_attributes(attributes=attribute)[attribute]
    except:
        existing_value = ''

    # convert dict attributes to JSON strings (sort keys for comparing)
    if attribute in ['Policy', 'RedrivePolicy']:
        value = json.dumps(value, sort_keys=True)
        if existing_value:
            existing_value = json.dumps(json.loads(existing_value), sort_keys=True)

    if str(value) != existing_value:
        if not check_mode:
            queue.set_attribute(attribute, value)
        return True

    return False
```
aws sqs_queue fail to update delivery_delay if delivery_delay is 0
##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report


##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
- sqs_queue
##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ ansible --version
ansible 2.4.1.0
  config file = None
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible
  executable location = /home/ubuntu/pyenvansible/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"

Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).

-->
- N/A
##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
- N/A
##### SUMMARY
<!--- Explain the problem briefly -->
sqs_queue fail to set delivery_delay, if delivery_delay is 0
##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
Create a sqs queue, set delivery_delay to 1
- hosts: localhost
  connection: local

  tasks:
    - name: update sqs queues
      sqs_queue:
        name: "{{ item[0] }}"
        region: "{{ item[1] }}"
        default_visibility_timeout: 120
        message_retention_period: 345600
        maximum_message_size: 262144
        delivery_delay: '1'
        receive_message_wait_time: 0
      with_nested:
        - [ "DefaultLetterQueue" ]
        - [ "ap-northeast-1" ]

update delivery_delay to 0
- hosts: localhost
  connection: local

  tasks:
    - name: update sqs queues
      sqs_queue:
        name: "{{ item[0] }}"
        region: "{{ item[1] }}"
        default_visibility_timeout: 120
        message_retention_period: 345600
        maximum_message_size: 262144
        delivery_delay: '0'
        receive_message_wait_time: 0
      with_nested:
        - [ "DefaultLetterQueue" ]
        - [ "ap-northeast-1" ]
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
delivery_delay of DefaultLetterQueue updated to 0
##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ ansible-playbook create_test_sqs.yaml -vvvv
ansible-playbook 2.4.1.0
  config file = None
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible
  executable location = /home/ubuntu/pyenvansible/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
No config file found; using defaults
setting up inventory plugins
 [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: create_test_sqs.yaml ***************************************************************************************************************************************************
1 plays in create_test_sqs.yaml

PLAY [localhost] *****************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329 `" && echo ansible-tmp-1511159874.35-2558833681843
29="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpWSdfJc TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/se
tup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511159874.35-255883368184329/setup.py; rm -rf "/home/ubuntu/.ansible/tmp/
ansible-tmp-1511159874.35-255883368184329/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]                                                                                                                                                          [20/2186]
META: ran handlers

TASK [update sqs queues] *********************************************************************************************************************************************************
task path: /home/ubuntu/bbmobile_ansible/create_test_sqs.yaml:7
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/cloud/amazon/sqs_queue.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609 `" && echo ansible-tmp-1511159875.0-192614452333609
="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpozP4Fh TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/sqs_queue.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/sqs_
queue.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511159875.0-192614452333609/sqs_queue.py; rm -rf "/home/ubuntu/.ansible/t
mp/ansible-tmp-1511159875.0-192614452333609/" > /dev/null 2>&1 && sleep 0'
changed: [localhost] => (item=[u'DefaultLetterQueue', u'ap-northeast-1']) => {
    "changed": true,
    "default_visibility_timeout": "120",
    "delivery_delay": "1",
    "failed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": null,
            "aws_secret_key": null,
            "default_visibility_timeout": 120,
            "delivery_delay": 1,
            "ec2_url": null,
            "maximum_message_size": 262144,
            "message_retention_period": 345600,
            "name": "DefaultLetterQueue",
            "policy": null,
            "profile": null,
            "receive_message_wait_time": 0,
            "redrive_policy": null,
            "region": "ap-northeast-1",
            "security_token": null,
            "state": "present",
            "validate_certs": true
        }
    },
    "item": [
        "DefaultLetterQueue",
        "ap-northeast-1"
    ],
    "maximum_message_size": "262144",
    "message_retention_period": "345600",
    "name": "DefaultLetterQueue",
    "policy": null,
    "queue_arn": "arn:aws:sqs:ap-northeast-1:############:DefaultLetterQueue",
    "receive_message_wait_time": "0",
    "redrive_policy": null,
    "region": "ap-northeast-1"
}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0

Update delivery delay to 0
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ vim create_test_sqs.yaml
(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$ ansible-playbook create_test_sqs.yaml -vvvv
ansible-playbook 2.4.1.0
  config file = None
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible
  executable location = /home/ubuntu/pyenvansible/bin/ansible-playbook
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
No config file found; using defaults
setting up inventory plugins
 [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

Loading callback plugin default of type stdout, v2.0 from /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: create_test_sqs.yaml ***************************************************************************************************************************************************
1 plays in create_test_sqs.yaml

PLAY [localhost] *****************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252 `" && echo ansible-tmp-1511160051.36-1839599933222
52="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpHJa6wZ TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/se
tup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.36-183959993322252/setup.py; rm -rf "/home/ubuntu/.ansible/tmp/
ansible-tmp-1511160051.36-183959993322252/" > /dev/null 2>&1 && sleep 0'
ok: [localhost]                                                                                                                                                          [20/2281]
META: ran handlers

TASK [update sqs queues] *********************************************************************************************************************************************************
task path: /home/ubuntu/bbmobile_ansible/create_test_sqs.yaml:7
Using module file /home/ubuntu/pyenvansible/local/lib/python2.7/site-packages/ansible/modules/cloud/amazon/sqs_queue.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830 `" && echo ansible-tmp-1511160051.78-50724705419830
="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpT_1FIR TO /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/sqs_queue.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/ /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/sqs_
queue.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ubuntu/pyenvansible/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1511160051.78-50724705419830/sqs_queue.py; rm -rf "/home/ubuntu/.ansible/t
mp/ansible-tmp-1511160051.78-50724705419830/" > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=[u'DefaultLetterQueue', u'ap-northeast-1']) => {
    "changed": false,
    "default_visibility_timeout": "120",
    "delivery_delay": "1",
    "failed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": null,
            "aws_secret_key": null,
            "default_visibility_timeout": 120,
            "delivery_delay": 0,
            "ec2_url": null,
            "maximum_message_size": 262144,
            "message_retention_period": 345600,
            "name": "DefaultLetterQueue",
            "policy": null,
            "profile": null,
            "receive_message_wait_time": 0,
            "redrive_policy": null,
            "region": "ap-northeast-1",
            "security_token": null,
            "state": "present",
            "validate_certs": true
        }
    },
    "item": [
        "DefaultLetterQueue",
        "ap-northeast-1"
    ],
    "maximum_message_size": "262144",
    "message_retention_period": "345600",
    "name": "DefaultLetterQueue",
    "policy": null,
    "queue_arn": "arn:aws:sqs:ap-northeast-1:###############:DefaultLetterQueue",
    "receive_message_wait_time": "0",
    "redrive_policy": null,
    "region": "ap-northeast-1"
}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0

(pyenvansible) ubuntu@bbazhang:~/bbmobile_ansible$
```

##### POSSIBLE CAUSE
```
https://github.com/ansible/ansible/blob/d8b1cb9a634d0e828a7be39d4019a6215410e643/lib/ansible/modules/cloud/amazon/sqs_queue.py
line 235 to 255
def set_queue_attribute(queue, attribute, value, check_mode=False):
    if not value:     ########if value is 0, set_queue_attribute return without update
        return False

    try:
        existing_value = queue.get_attributes(attributes=attribute)[attribute]
    except:
        existing_value = ''

    # convert dict attributes to JSON strings (sort keys for comparing)
    if attribute in ['Policy', 'RedrivePolicy']:
        value = json.dumps(value, sort_keys=True)
        if existing_value:
            existing_value = json.dumps(json.loads(existing_value), sort_keys=True)

    if str(value) != existing_value:
        if not check_mode:
            queue.set_attribute(attribute, value)
        return True

    return False
```


Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/sqs_queue.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/sqs_queue.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @loia @nadirollo @nand0p @willthames
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/sqs_queue.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/sqs_queue.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @loia @nadirollo @nand0p @willthames
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/sqs_queue.py b/lib/ansible/modules/cloud/amazon/sqs_queue.py
--- a/lib/ansible/modules/cloud/amazon/sqs_queue.py
+++ b/lib/ansible/modules/cloud/amazon/sqs_queue.py
@@ -233,7 +233,7 @@ def update_sqs_queue(queue,
 
 
 def set_queue_attribute(queue, attribute, value, check_mode=False):
-    if not value:
+    if not value and value != 0:
         return False
 
     try:


Test patch: