Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #1627/3cf69cd4 backport][stable-4] Fix KeyError when Description is not present in ssm_parameter #1630

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/aws_ssm_parameter_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,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/aws_ssm_parameter_store/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