From f98b2f4ca2f3bdd5dca6562e960f3fa1641f6829 Mon Sep 17 00:00:00 2001 From: Mark Woolley Date: Sat, 22 Jan 2022 13:55:10 +0000 Subject: [PATCH] Make some adjustments and fix tests --- plugins/modules/dynamodb_table.py | 15 +++++++-------- .../targets/dynamodb_table/meta/main.yml | 4 +++- .../targets/dynamodb_table/tasks/main.yml | 13 ++++++++++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/plugins/modules/dynamodb_table.py b/plugins/modules/dynamodb_table.py index 4914522feb7..14a6c5b5eba 100644 --- a/plugins/modules/dynamodb_table.py +++ b/plugins/modules/dynamodb_table.py @@ -125,7 +125,6 @@ description: - The class of the table choices: ['STANDARD', 'STANDARD_INFREQUENT_ACCESS'] - default: 'STANDARD' type: str version_added: 3.1.0 tags: @@ -417,7 +416,7 @@ def compatability_results(current_table): billing_mode=billing_mode, region=module.region, table_name=current_table.get('table_name', None), - table_class=current_table.get('table_class', None), + table_class=current_table.get('table_class_summary', {}).get('table_class', None), table_status=current_table.get('table_status', None), tags=current_table.get('tags', {}), ) @@ -777,12 +776,8 @@ def _update_table(current_table): # Update table_class use exisiting if none is defined if module.params.get('table_class'): - table_class = module.params.get('table_class') - else: - table_class = current_table.get('table_class') - - if table_class != current_table.get('billing_mode'): - changes['TableClass'] = table_class + if module.params.get('table_class') != current_table.get('table_class'): + changes['TableClass'] = module.params.get('table_class') global_index_changes = _global_index_changes(current_table) if global_index_changes: @@ -1021,6 +1016,10 @@ def main(): ) client = module.client('dynamodb', retry_decorator=retry_decorator) + if module.params.get('table_class'): + if not module.botocore_at_least("1.23.18"): + module.fail_json(msg='botocore version >= 1.23.18 is required setting table_class') + current_table = get_dynamodb_table() changed = False table = None diff --git a/tests/integration/targets/dynamodb_table/meta/main.yml b/tests/integration/targets/dynamodb_table/meta/main.yml index 07faa217762..504e72117b6 100644 --- a/tests/integration/targets/dynamodb_table/meta/main.yml +++ b/tests/integration/targets/dynamodb_table/meta/main.yml @@ -1,2 +1,4 @@ dependencies: - - prepare_tests + - role: setup_botocore_pip + vars: + botocore_version: "1.23.18" diff --git a/tests/integration/targets/dynamodb_table/tasks/main.yml b/tests/integration/targets/dynamodb_table/tasks/main.yml index 39c725de0bb..21c7f465b20 100644 --- a/tests/integration/targets/dynamodb_table/tasks/main.yml +++ b/tests/integration/targets/dynamodb_table/tasks/main.yml @@ -574,7 +574,6 @@ - delete_table is not changed # ============================================== - - name: Create complex table - check_mode dynamodb_table: state: present @@ -589,6 +588,8 @@ tags: "{{ tags_default }}" indexes: "{{ indexes }}" register: create_complex_table + vars: + ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}" check_mode: True - name: Check results - Create complex table - check_mode @@ -611,6 +612,8 @@ tags: "{{ tags_default }}" indexes: "{{ indexes }}" register: create_complex_table + vars: + ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}" - name: Check results - Create complex table assert: @@ -653,6 +656,8 @@ tags: "{{ tags_default }}" indexes: "{{ indexes }}" register: create_complex_table + vars: + ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}" check_mode: True - name: Check results - Create complex table - idempotent - check_mode @@ -675,6 +680,8 @@ tags: "{{ tags_default }}" indexes: "{{ indexes }}" register: create_complex_table + vars: + ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}" - name: Check results - Create complex table - idempotent assert: @@ -712,6 +719,8 @@ name: "{{ table_name }}" table_class: "STANDARD" register: update_class + vars: + ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}" check_mode: True - name: Check results - Update table class - check_mode @@ -725,6 +734,8 @@ state: present name: "{{ table_name }}" table_class: "STANDARD" + vars: + ansible_python_interpreter: "{{ botocore_virtualenv_interpreter }}" register: update_class - name: Check results - Update table class