From 02b73872aef1a2823ebc9b91782568e88a23624c Mon Sep 17 00:00:00 2001 From: Tom Benninger Date: Fri, 25 Sep 2020 08:50:48 -0400 Subject: [PATCH] Type conversion issue for creating read replicas (#229) * Type conversion issue for creating read replicas * Added changelog snippet * Updated tests This commit was initially merged in https://github.com/ansible-collections/community.aws See: https://github.com/ansible-collections/community.aws/commit/cd938b2c0ef3d1bc98ac68b217187f45278af2b1 --- plugins/modules/rds_instance.py | 6 ++++-- .../rds_instance/tasks/test_read_replica.yml | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/modules/rds_instance.py b/plugins/modules/rds_instance.py index e93322cc61b..ea2e8ba11b1 100644 --- a/plugins/modules/rds_instance.py +++ b/plugins/modules/rds_instance.py @@ -842,8 +842,10 @@ def get_parameters(client, module, parameters, method_name): if parameters.get('ProcessorFeatures') == [] and not method_name == 'modify_db_instance': parameters.pop('ProcessorFeatures') - if method_name == 'create_db_instance' and parameters.get('Tags'): - parameters['Tags'] = ansible_dict_to_boto3_tag_list(parameters['Tags']) + if method_name == 'create_db_instance' or method_name == 'create_db_instance_read_replica': + if parameters.get('Tags'): + parameters['Tags'] = ansible_dict_to_boto3_tag_list(parameters['Tags']) + if method_name == 'modify_db_instance': parameters = get_options_with_changing_values(client, module, parameters) diff --git a/tests/integration/targets/rds_instance/tasks/test_read_replica.yml b/tests/integration/targets/rds_instance/tasks/test_read_replica.yml index 157fd10597e..3ed091b3dc8 100644 --- a/tests/integration/targets/rds_instance/tasks/test_read_replica.yml +++ b/tests/integration/targets/rds_instance/tasks/test_read_replica.yml @@ -39,6 +39,9 @@ db_instance_class: "{{ db_instance_class }}" allocated_storage: "{{ allocated_storage }}" region: "{{ region_src }}" + tags: + Name: "{{ instance_id }}" + Created_by: Ansible rds_instance tests <<: *aws_connection_info register: source_db @@ -59,9 +62,20 @@ db_instance_class: "{{ db_instance_class }}" allocated_storage: "{{ allocated_storage }}" region: "{{ region_dest }}" + tags: + Name: "{{ instance_id }}" + Created_by: Ansible rds_instance tests <<: *aws_connection_info register: result + - assert: + that: + - result.changed + - "result.db_instance_identifier == '{{ instance_id }}-replica'" + - "result.tags | length == 2" + - "result.tags.Name == '{{ instance_id }}'" + - "result.tags.Created_by == 'Ansible rds_instance tests'" + - name: Test idempotence with a read replica rds_instance: id: "{{ instance_id }}-replica" @@ -73,6 +87,9 @@ db_instance_class: "{{ db_instance_class }}" allocated_storage: "{{ allocated_storage }}" region: "{{ region_dest }}" + tags: + Name: "{{ instance_id }}" + Created_by: Ansible rds_instance tests <<: *aws_connection_info register: result @@ -92,6 +109,9 @@ db_instance_class: "{{ db_instance_class }}" allocated_storage: "{{ allocated_storage }}" region: "{{ region_dest }}" + tags: + Name: "{{ instance_id }}" + Created_by: Ansible rds_instance tests <<: *aws_connection_info register: result