Skip to content

Commit

Permalink
fix io1 logic
Browse files Browse the repository at this point in the history
  • Loading branch information
marknet15 committed Jan 23, 2022
1 parent 16a54a7 commit 2bf8878
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 11 additions & 11 deletions plugins/modules/rds_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2bf8878

Please sign in to comment.