Skip to content

Commit

Permalink
Make deprecated updates in dynamodbo_table module fail (#837)
Browse files Browse the repository at this point in the history
Make deprecated updates in dynamodbo_table module fail

SUMMARY
Make deprecated primary key updates and all type index includes update fail in dynamodb_table module for 3.0.0
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
dynamodb_table
ADDITIONAL INFORMATION
Both parts were previously deprecated and are currently ignored, this PR actually makes those ignore updates fail on attempts to pass the bad config.

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
  • Loading branch information
marknet15 authored Dec 18, 2021
1 parent a3d940a commit db8a14d
Show file tree
Hide file tree
Showing 5 changed files with 522 additions and 562 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
breaking_changes:
- dynamodb_table - deprecated updates currently ignored for primary keys and global_all indexes will now result in a failure.
(https://github.com/ansible-collections/community.aws/pull/837).
13 changes: 3 additions & 10 deletions plugins/modules/dynamodb_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,9 @@ def _generate_index(index, include_throughput=True):
projection['NonKeyAttributes'] = non_key_attributes
else:
if non_key_attributes:
module.deprecate(
module.fail_json(
"DynamoDB does not support specifying non-key-attributes ('includes') for "
"indexes of type 'all'. Attempts to set this attributes are currently "
"ignored, but in future will result in a failure. "
"Index name: {0}".format(index['name']),
version='3.0.0', collection_name='community.aws')
"indexes of type 'all'. Index name: {0}".format(index['name']))

idx = dict(
IndexName=index['name'],
Expand Down Expand Up @@ -857,11 +854,7 @@ def _update_tags(current_table):
def update_table(current_table):
primary_index_changes = _primary_index_changes(current_table)
if primary_index_changes:
module.deprecate("DynamoDB does not support updating the Primary keys on a table. "
"Attempts to change the keys are currently ignored, but in future will "
"result in a failure. "
"Changed paramters are {0}".format(primary_index_changes),
version='3.0.0', collection_name='community.aws')
module.fail_json("DynamoDB does not support updating the Primary keys on a table. Changed paramters are: {0}".format(primary_index_changes))

changed = False
changed |= _update_table(current_table)
Expand Down
17 changes: 14 additions & 3 deletions tests/integration/targets/dynamodb_table/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
table_name: "{{ resource_prefix }}"
table_name_on_demand: "{{ resource_prefix }}-pay-per-request"
table_name_on_demand_complex: "{{ resource_prefix }}-pay-per-request-complex"

table_index: "id"
table_index_type: "NUMBER"
Expand All @@ -22,13 +23,23 @@ indexes:
type: global_all
hash_key_name: foo
range_key_name: bar
includes:
- another_field
- another_field2
read_capacity: 5
write_capacity: 5

indexes_pay_per_request:
- name: NamedIndex
type: global_include
hash_key_name: idx
range_key_name: create_time
includes:
- other_field
- other_field2
- name: AnotherIndex
type: global_all
hash_key_name: foo
range_key_name: bar

indexes_pay_per_request_bad:
- name: NamedIndex
type: global_include
hash_key_name: idx
Expand Down
Loading

0 comments on commit db8a14d

Please sign in to comment.