Skip to content

Commit

Permalink
fix: mq_broker creation with tags; closes #1832 (#1886)
Browse files Browse the repository at this point in the history
mq_broker - fix creation with tags

SUMMARY
Fixes #1832
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
mq_broker
ADDITIONAL INFORMATION
before:
ok: [testhost] => {
    "result_c1": {
        "broker": {
            "authentication_strategy": "simple",
            "auto_minor_version_upgrade": true,
            "broker_arn": "arn:aws:mq:ca-central-1:196233192477:broker:ansible-test-22180167-ali-mq:b-ebaf0e8c-4414-4ac1-9517-67c7968e677d",
            "broker_id": "b-ebaf0e8c-4414-4ac1-9517-67c7968e677d",
            "broker_instances": [],
            "broker_name": "ansible-test-22180167-ali-mq",
            "broker_state": "CREATION_IN_PROGRESS",
            "configurations": {
                "history": [],
                "pending": {
                    "id": "c-2c5fc151-0091-4c1e-a590-096ffc633d07",
                    "revision": 1
                }
            },
            "created": "2023-07-12T10:02:38.207000+00:00",
            "deployment_mode": "SINGLE_INSTANCE",
            "encryption_options": {
                "kms_key_id": "arn:aws:kms:ca-central-1:196233192477:key/7cdaffb8-ad16-4623-b370-efb041df45cc",
                "use_aws_owned_key": false
            },
            "engine_type": "ActiveMQ",
            "engine_version": "5.17.3",
            "host_instance_type": "mq.t3.micro",
            "logs": {
                "audit": false,
                "audit_log_group": "/aws/amazonmq/broker/b-ebaf0e8c-4414-4ac1-9517-67c7968e677d/audit",
                "general": false,
                "general_log_group": "/aws/amazonmq/broker/b-ebaf0e8c-4414-4ac1-9517-67c7968e677d/general"
            },
            "maintenance_window_start_time": {
                "day_of_week": "TUESDAY",
                "time_of_day": "17:00",
                "time_zone": "UTC"
            },
            "publicly_accessible": false,
            "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": "1784",
                    "content-type": "application/json",
                    "date": "Wed, 12 Jul 2023 10:02:40 GMT",
                    "expires": "0",
                    "pragma": "no-cache",
                    "x-amz-apigw-id": "H8gKCFJMYosFrgA=",
                    "x-amzn-requestid": "b7280747-8f0e-4c9f-9f32-e78b84eed485",
                    "x-amzn-trace-id": "Root=1-64ae7a3f-20b2061251100a3d6ed1f9a2"
                },
                "http_status_code": 200,
                "request_id": "b7280747-8f0e-4c9f-9f32-e78b84eed485",
                "retry_attempts": 0
            },
            "security_groups": [
                "sg-0aa726c0444fc83f7"
            ],
            "storage_type": "efs",
            "subnet_ids": [
                "subnet-0179f9e2489397b2e"
            ],
            "tags": {},
            "users": [
                {
                    "pending_change": "CREATE",
                    "username": "admin"
                }
            ]
        },
        "changed": false,
        "failed": false,
        "resource_actions": [
            "mq:DescribeBroker"
        ]
    }
}

after:
ok: [testhost] => {
    "result_c1": {
        "broker": {
            "authentication_strategy": "simple",
            "auto_minor_version_upgrade": true,
            "broker_arn": "arn:aws:mq:ca-central-1:196233192477:broker:ansible-test-25482350-ali-mq:b-3dd2d767-7740-4889-b004-62d771b36661",
            "broker_id": "b-3dd2d767-7740-4889-b004-62d771b36661",
            "broker_instances": [],
            "broker_name": "ansible-test-25482350-ali-mq",
            "broker_state": "CREATION_IN_PROGRESS",
            "configurations": {
                "history": [],
                "pending": {
                    "id": "c-6e226c2d-4ae1-4748-9720-b127ac041824",
                    "revision": 1
                }
            },
            "created": "2023-07-12T09:19:49.020000+00:00",
            "deployment_mode": "SINGLE_INSTANCE",
            "encryption_options": {
                "kms_key_id": "arn:aws:kms:ca-central-1:196233192477:key/7cdaffb8-ad16-4623-b370-efb041df45cc",
                "use_aws_owned_key": false
            },
            "engine_type": "ActiveMQ",
            "engine_version": "5.17.3",
            "host_instance_type": "mq.t3.micro",
            "logs": {
                "audit": false,
                "audit_log_group": "/aws/amazonmq/broker/b-3dd2d767-7740-4889-b004-62d771b36661/audit",
                "general": false,
                "general_log_group": "/aws/amazonmq/broker/b-3dd2d767-7740-4889-b004-62d771b36661/general"
            },
            "maintenance_window_start_time": {
                "day_of_week": "FRIDAY",
                "time_of_day": "17:00",
                "time_zone": "UTC"
            },
            "publicly_accessible": false,
            "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": "1814",
                    "content-type": "application/json",
                    "date": "Wed, 12 Jul 2023 09:19:51 GMT",
                    "expires": "0",
                    "pragma": "no-cache",
                    "x-amz-apigw-id": "H8Z4pGfC4osFeAg=",
                    "x-amzn-requestid": "f469a522-80b7-4da4-af53-875f50962d2c",
                    "x-amzn-trace-id": "Root=1-64ae7037-43906aac58ab1798156f7003"
                },
                "http_status_code": 200,
                "request_id": "f469a522-80b7-4da4-af53-875f50962d2c",
                "retry_attempts": 0
            },
            "security_groups": [
                "sg-0e83937e543dc249c"
            ],
            "storage_type": "efs",
            "subnet_ids": [
                "subnet-054a759ac833bf4b3"
            ],
            "tags": {
                "workload_type": "other"
            },
            "users": [
                {
                    "pending_change": "CREATE",
                    "username": "admin"
                }
            ]
        },
        "changed": false,
        "failed": false,
        "resource_actions": [
            "mq:DescribeBroker"
        ]
    }
}

Reviewed-by: Alina Buzachis
(cherry picked from commit 9c85fec)
  • Loading branch information
alialkhalidi authored and patchback[bot] committed Oct 20, 2023
1 parent 68d7bea commit 97e33f0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/1832-mq_broker_tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- mq_broker - ensure broker is created with ``tags`` when passed (https://github.com/ansible-collections/community.aws/issues/1832).
1 change: 1 addition & 0 deletions plugins/modules/mq_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
"storage_type": "StorageType",
"subnet_ids": "SubnetIds",
"users": "Users",
"tags": "Tags",
}


Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/mq/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions tests/integration/targets/mq/tasks/broker_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/mq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
- name: cleanup broker
include_tasks: broker_cleanup.yml

- include_tasks: env_cleanup.yml
- include_tasks: env_cleanup.yml

0 comments on commit 97e33f0

Please sign in to comment.