Skip to content

Commit

Permalink
Fix KeyError when Description is not present in ssm_parameter (#1627)
Browse files Browse the repository at this point in the history
Fix KeyError when Description is not present in ssm_parameter

SUMMARY
Fixes #1471
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ssm_parameter
ADDITIONAL INFORMATION

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Mark Chappell <None>
(cherry picked from commit 3cf69cd)
  • Loading branch information
rwha authored and patchback[bot] committed Dec 22, 2022
1 parent 751dcb2 commit a9a1651
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ssm_parameter - Fix a ``KeyError`` when adding a description to an existing parameter (https://github.com/ansible-collections/community.aws/issues/1471).
2 changes: 1 addition & 1 deletion plugins/modules/ssm_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def create_update_parameter(client, module):
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="getting description value")

if describe_existing_parameter['Description'] != args['Description']:
if describe_existing_parameter.get('Description') != args['Description']:
(changed, response) = update_parameter(client, module, **args)
if changed:
_wait_updated(client, module, module.params.get('name'), original_version)
Expand Down
24 changes: 24 additions & 0 deletions tests/integration/targets/ssm_parameter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,30 @@
that:
- result is not changed

- name: Create key/value pair in aws parameter store with no description
aws_ssm_parameter_store:
name: '{{ simple_name }}'
value: '{{ simple_value }}'
register: result

- assert:
that:
- result is changed
- '"description" not in result.parameter_metadata'

- name: Add a description
aws_ssm_parameter_store:
name: '{{ simple_name }}'
value: '{{ simple_value }}'
description: '{{ simple_description }}'
register: result

- assert:
that:
- result is changed
- '"description" in result.parameter_metadata'
- result.parameter_metadata.description == simple_description

always:
# ============================================================
- name: Delete remaining key/value pairs in aws parameter store
Expand Down

0 comments on commit a9a1651

Please sign in to comment.