From 2bf8878a1f2588eebc279b337267b19a9d9c9463 Mon Sep 17 00:00:00 2001 From: Mark Woolley Date: Sat, 22 Jan 2022 12:39:51 +0000 Subject: [PATCH] fix io1 logic --- plugins/modules/rds_instance.py | 22 +++++++++---------- .../roles/rds_instance/tasks/test_complex.yml | 2 ++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/modules/rds_instance.py b/plugins/modules/rds_instance.py index b381feea2aa..37dd707e4aa 100644 --- a/plugins/modules/rds_instance.py +++ b/plugins/modules/rds_instance.py @@ -890,17 +890,16 @@ def get_options_with_changing_values(client, module, parameters): updated_parameters.update(get_changing_options_with_consistent_keys(parameters, instance)) parameters = updated_parameters - if module.params['storage_type'] == 'io1': - # Bundle Iops and AllocatedStorage together while updating RDS Instance - if module.params.get('iops') and module.params.get('allocated_storage'): - parameters['Iops'] = module.params['iops'] - parameters['AllocatedStorage'] = module.params['allocated_storage'] - elif module.params.get('iops'): - parameters['Iops'] = module.params['iops'] - parameters['AllocatedStorage'] = instance.get('AllocatedStorage') - elif module.params.get('allocated_storage'): - parameters['Iops'] = instance.get('Iops') - parameters['AllocatedStorage'] = module.params['allocated_storage'] + if instance.get['StorageType'] == 'io1': + # Bundle Iops and AllocatedStorage while updating io1 RDS Instance + current_iops = instance.get('Iops') + current_allocated_storage = instance.get('AllocatedStorage') + new_iops = module.params.get('iops') + new_allocated_storage = module.params.get('allocated_storage') + + if current_iops != new_iops or current_allocated_storage != new_allocated_storage: + parameters['AllocatedStorage'] = new_allocated_storage + parameters['Iops'] = new_iops if parameters.get('NewDBInstanceIdentifier') and instance.get('PendingModifiedValues', {}).get('DBInstanceIdentifier'): if parameters['NewDBInstanceIdentifier'] == instance['PendingModifiedValues']['DBInstanceIdentifier'] and not apply_immediately: @@ -1191,6 +1190,7 @@ def main(): ('engine', 'aurora', ('db_cluster_identifier',)), ('engine', 'aurora-mysql', ('db_cluster_identifier',)), ('engine', 'aurora-postresql', ('db_cluster_identifier',)), + ('storage_type', 'io1', ('iops', 'allocated_storage')), ('creation_source', 'snapshot', ('snapshot_identifier', 'engine')), ('creation_source', 's3', ( 's3_bucket_name', 'engine', 'master_username', 'master_user_password', diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_complex.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_complex.yml index bff96167d2e..61cf5971c2c 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_complex.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_complex.yml @@ -60,6 +60,7 @@ auto_minor_version_upgrade: false monitoring_interval: "{{ monitoring_interval }}" monitoring_role_arn: "{{ enhanced_monitoring_role.arn }}" + iops: "{{ iops }}" port: 1150 max_allocated_storage: 150 apply_immediately: True @@ -89,6 +90,7 @@ auto_minor_version_upgrade: false monitoring_interval: "{{ monitoring_interval }}" monitoring_role_arn: "{{ enhanced_monitoring_role.arn }}" + iops: "{{ iops }}" port: 1150 max_allocated_storage: 150 apply_immediately: True