diff --git a/changelogs/fragments/195-aws_codecommit-empty-description.yaml b/changelogs/fragments/195-aws_codecommit-empty-description.yaml new file mode 100644 index 00000000000..2ab88e6bc7a --- /dev/null +++ b/changelogs/fragments/195-aws_codecommit-empty-description.yaml @@ -0,0 +1,2 @@ +bugfixes: +- aws_codecommit - fixes issue where module execution would fail if an existing repository has empty description (https://github.com/ansible-collections/community.aws/pull/195) diff --git a/plugins/modules/aws_codecommit.py b/plugins/modules/aws_codecommit.py index 5fe907cc37d..18fc10a2d69 100644 --- a/plugins/modules/aws_codecommit.py +++ b/plugins/modules/aws_codecommit.py @@ -162,6 +162,8 @@ def process(self): result['changed'] = True else: metadata = self._get_repository()['repositoryMetadata'] + if not metadata.get('repositoryDescription'): + metadata['repositoryDescription'] = '' if metadata['repositoryDescription'] != self._module.params['description']: if not self._check_mode: self._update_repository() diff --git a/tests/integration/targets/aws_codecommit/tasks/main.yml b/tests/integration/targets/aws_codecommit/tasks/main.yml index 29b9f6b27e5..acf194e1ef1 100644 --- a/tests/integration/targets/aws_codecommit/tasks/main.yml +++ b/tests/integration/targets/aws_codecommit/tasks/main.yml @@ -96,6 +96,35 @@ that: - output is not changed + - name: Create a repository without description + aws_codecommit: + name: "{{ resource_prefix }}_repo" + state: present + register: output + - assert: + that: + - output is changed + - output.repository_metadata.repository_name == '{{ resource_prefix }}_repo' + + - name: No-op update to repository without description + aws_codecommit: + name: "{{ resource_prefix }}_repo" + state: present + register: output + - assert: + that: + - output is not changed + - output.repository_metadata.repository_name == '{{ resource_prefix }}_repo' + + - name: Delete a repository without description + aws_codecommit: + name: "{{ resource_prefix }}_repo" + state: absent + register: output + - assert: + that: + - output is changed + always: ###### TEARDOWN STARTS HERE ###### - name: Delete a repository