Skip to content

Commit

Permalink
Type conversion issue for creating read replicas (ansible-collections…
Browse files Browse the repository at this point in the history
…#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: ansible-collections/community.aws@cd938b2
  • Loading branch information
tombenninger authored and alinabuzachis committed Sep 9, 2022
1 parent d51bc94 commit 39a6377
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/modules/rds_instance.py
Expand Up @@ -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)

Expand Down
20 changes: 20 additions & 0 deletions tests/integration/targets/rds_instance/tasks/test_read_replica.yml
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 39a6377

Please sign in to comment.