Skip to content

Commit

Permalink
Make some adjustments and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marknet15 committed Jan 22, 2022
1 parent 61665b1 commit f98b2f4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
15 changes: 7 additions & 8 deletions plugins/modules/dynamodb_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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', {}),
)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/targets/dynamodb_table/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dependencies:
- prepare_tests
- role: setup_botocore_pip
vars:
botocore_version: "1.23.18"
13 changes: 12 additions & 1 deletion tests/integration/targets/dynamodb_table/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@
- delete_table is not changed

# ==============================================

- name: Create complex table - check_mode
dynamodb_table:
state: present
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f98b2f4

Please sign in to comment.