From 9c85fec7e3729e2ba17d9988c7f8910c9a9f693f Mon Sep 17 00:00:00 2001 From: alialkhalidi <75764610+alialkhalidi@users.noreply.github.com> Date: Fri, 20 Oct 2023 08:51:47 -0400 Subject: [PATCH] fix: mq_broker creation with tags; closes #1832 (#1886) 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 --- changelogs/fragments/1832-mq_broker_tags.yml | 2 ++ plugins/modules/mq_broker.py | 1 + tests/integration/targets/mq/defaults/main.yml | 2 ++ tests/integration/targets/mq/tasks/broker_tests.yml | 2 ++ tests/integration/targets/mq/tasks/main.yml | 2 +- 5 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/1832-mq_broker_tags.yml diff --git a/changelogs/fragments/1832-mq_broker_tags.yml b/changelogs/fragments/1832-mq_broker_tags.yml new file mode 100644 index 00000000000..b2320dd3c71 --- /dev/null +++ b/changelogs/fragments/1832-mq_broker_tags.yml @@ -0,0 +1,2 @@ +bugfixes: + - mq_broker - ensure broker is created with ``tags`` when passed (https://github.com/ansible-collections/community.aws/issues/1832). \ No newline at end of file diff --git a/plugins/modules/mq_broker.py b/plugins/modules/mq_broker.py index 5c73e3c9104..25377407c2c 100644 --- 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", } diff --git a/tests/integration/targets/mq/defaults/main.yml b/tests/integration/targets/mq/defaults/main.yml index 896ba8afa7d..2199c2f637f 100644 --- 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 index 958b80cb205..d4d399da7c1 100644 --- 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 index 2055700480b..e84367a76c2 100644 --- 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