Repository: ansible-collections/community.aws

Issue:
mq_broker: Tagging a broker on creation does not work
### Summary

When creating a new MQ broker using the following task, the broker does not get tagged. 

```
- name: create broker with minimal parameters
  mq_broker:
    broker_name: "{{ broker_name }}"
    security_groups: "{{ broker_sg_ids.split(',') }}"
    subnet_ids: "{{ broker_subnet_ids.split(',') }}"
    tags:
      "Foo": "Bar"
      "FooBar": "foobar"
```

Actual result:

```
changed: [testhost] => {
    "broker": {
        "broker_arn": "arn:aws:mq:us-east-1:123456789100:broker:ansible-test-52903175--mq:b-70e0807b-102d-42ae-8805-94ec6395436c",
        "broker_id": "b-70e0807b-102d-42ae-8805-94ec6395436c",
        "response_metadata": {
            "http_headers": {
                "access-control-allow-origin": "*",
                "access-control-expose-headers": "x-amzn-errortype,x-amzn-requestid,x-amzn-errormessage,x-amzn-trace-id,x-amz-apigw-id,date",
                "cache-control": "no-cache; no-store, must-revalidate, private",
                "connection": "keep-alive",
                "content-length": "191",
                "content-type": "application/json",
                "date": "Wed, 31 May 2023 13:25:16 GMT",
                "expires": "0",
                "pragma": "no-cache",
                "x-amz-apigw-id": "FyidUFppIAMF1zw=",
                "x-amzn-requestid": "12345bcb-5678-890d-972c-26a92712aaeb",
                "x-amzn-trace-id": "Root=1-64774abb-2b3bf58a2b0cbf7800afdef6"
            },
            "http_status_code": 200,
            "request_id": "59392bcb-5406-460d-972c-26a92712aaeb",
            "retry_attempts": 0
        }
    },
```

### Issue Type

Bug Report

### Component Name

mq_broker

### Ansible Version

```console (paste below)
$ ansible --version

ansible [core 2.14.3]

```

### Collection Versions

```console (paste below)
$ ansible-galaxy collection list

Collection                    Version
----------------------------- -------
amazon.aws                    6.0.0  
community.aws                 6.0.0  
```


### AWS SDK versions

```console (paste below)
$ pip show boto boto3 botocore

Name: boto3
Version: 1.22.0
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /Users/alinabuzachis/anaconda3/envs/py310/lib/python3.10/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: gouttelette
---
Name: botocore
Version: 1.25.13
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /Users/alinabuzachis/anaconda3/envs/py310/lib/python3.10/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: aiobotocore, awscli, boto3, s3transfer
```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed

```


### OS / Environment

_No response_

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)

```


### Expected Results

Create an MQ broker using the task I pasted before.

### Actual Results

```console (paste below)

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
mq_broker: Tagging a broker on creation does not work
### Summary

When creating a new MQ broker using the following task, the broker does not get tagged. 

```
- name: create broker with minimal parameters
  mq_broker:
    broker_name: "{{ broker_name }}"
    security_groups: "{{ broker_sg_ids.split(',') }}"
    subnet_ids: "{{ broker_subnet_ids.split(',') }}"
    tags:
      "Foo": "Bar"
      "FooBar": "foobar"
```

Actual result:

```
changed: [testhost] => {
    "broker": {
        "broker_arn": "arn:aws:mq:us-east-1:123456789100:broker:ansible-test-52903175--mq:b-70e0807b-102d-42ae-8805-94ec6395436c",
        "broker_id": "b-70e0807b-102d-42ae-8805-94ec6395436c",
        "response_metadata": {
            "http_headers": {
                "access-control-allow-origin": "*",
                "access-control-expose-headers": "x-amzn-errortype,x-amzn-requestid,x-amzn-errormessage,x-amzn-trace-id,x-amz-apigw-id,date",
                "cache-control": "no-cache; no-store, must-revalidate, private",
                "connection": "keep-alive",
                "content-length": "191",
                "content-type": "application/json",
                "date": "Wed, 31 May 2023 13:25:16 GMT",
                "expires": "0",
                "pragma": "no-cache",
                "x-amz-apigw-id": "FyidUFppIAMF1zw=",
                "x-amzn-requestid": "12345bcb-5678-890d-972c-26a92712aaeb",
                "x-amzn-trace-id": "Root=1-64774abb-2b3bf58a2b0cbf7800afdef6"
            },
            "http_status_code": 200,
            "request_id": "59392bcb-5406-460d-972c-26a92712aaeb",
            "retry_attempts": 0
        }
    },
```

### Issue Type

Bug Report

### Component Name

mq_broker

### Ansible Version

```console (paste below)
$ ansible --version

ansible [core 2.14.3]

```

### Collection Versions

```console (paste below)
$ ansible-galaxy collection list

Collection                    Version
----------------------------- -------
amazon.aws                    6.0.0  
community.aws                 6.0.0  
```


### AWS SDK versions

```console (paste below)
$ pip show boto boto3 botocore

Name: boto3
Version: 1.22.0
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /Users/alinabuzachis/anaconda3/envs/py310/lib/python3.10/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: gouttelette
---
Name: botocore
Version: 1.25.13
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: 
License: Apache License 2.0
Location: /Users/alinabuzachis/anaconda3/envs/py310/lib/python3.10/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: aiobotocore, awscli, boto3, s3transfer
```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed

```


### OS / Environment

_No response_

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)

```


### Expected Results

Create an MQ broker using the task I pasted before.

### Actual Results

```console (paste below)

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:

Resolving patch:
diff --git a/plugins/modules/mq_broker.py b/plugins/modules/mq_broker.py
--- a/plugins/modules/mq_broker.py
+++ b/plugins/modules/mq_broker.py
@@ -237,6 +237,7 @@
     "storage_type": "StorageType",
     "subnet_ids": "SubnetIds",
     "users": "Users",
+    "tags": "Tags",
 }
 
 


Test patch:
diff --git a/tests/integration/targets/mq/defaults/main.yml b/tests/integration/targets/mq/defaults/main.yml
--- a/tests/integration/targets/mq/defaults/main.yml
+++ b/tests/integration/targets/mq/defaults/main.yml
@@ -5,3 +5,5 @@ vpc_name: "{{ resource_prefix }}-vpc"
 vpc_cidr: "10.0.0.0/16"
 subnet_cidr: "10.0.1.0/24"
 sg_name: "{{resource_prefix}}-sg"
+tags:
+  workload_type: other
\ No newline at end of file
diff --git a/tests/integration/targets/mq/tasks/broker_tests.yml b/tests/integration/targets/mq/tasks/broker_tests.yml
--- a/tests/integration/targets/mq/tasks/broker_tests.yml
+++ b/tests/integration/targets/mq/tasks/broker_tests.yml
@@ -3,6 +3,7 @@
     broker_name: "{{ broker_name }}"
     security_groups: "{{ broker_sg_ids.split(',') }}"
     subnet_ids: "{{ broker_subnet_ids.split(',') }}"
+    tags: "{{ tags }}"
   register: result
 - set_fact:
     broker_id: "{{ result.broker['broker_id'] }}"
@@ -20,6 +21,7 @@
       - result_c1.broker['broker_name'] == broker_name
       - result_c1.broker['broker_state'] == 'CREATION_IN_PROGRESS'
       - ( result_c1.broker['storage_type'] | upper ) == 'EFS'
+      - result_c1.broker['tags'] == tags
   when: not ansible_check_mode
 - debug:
     msg: "Wait until broker {{ broker_name }} ({{ broker_id }}) enters running state. This may take several minutes"
diff --git a/tests/integration/targets/mq/tasks/main.yml b/tests/integration/targets/mq/tasks/main.yml
--- a/tests/integration/targets/mq/tasks/main.yml
+++ b/tests/integration/targets/mq/tasks/main.yml
@@ -32,4 +32,4 @@
     - name: cleanup broker
       include_tasks: broker_cleanup.yml
 
-    - include_tasks: env_cleanup.yml
\ No newline at end of file
+    - include_tasks: env_cleanup.yml