diff --git a/changelogs/fragments/backup_selection-return_snake_case.yml b/changelogs/fragments/backup_selection-return_snake_case.yml new file mode 100644 index 00000000000..16d502a648c --- /dev/null +++ b/changelogs/fragments/backup_selection-return_snake_case.yml @@ -0,0 +1,2 @@ +trivial: + - "backup_selection_info ensure result is returned as snake_case rather than CamelCase." diff --git a/plugins/modules/backup_selection_info.py b/plugins/modules/backup_selection_info.py index dcb8f6571a2..2beb66db03e 100644 --- a/plugins/modules/backup_selection_info.py +++ b/plugins/modules/backup_selection_info.py @@ -114,6 +114,7 @@ from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.backup import get_selection_details +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict def main(): @@ -133,7 +134,7 @@ def main(): result["backup_selections"] = get_selection_details( module, client, module.params.get("backup_plan_name"), module.params.get("backup_selection_names") ) - module.exit_json(**result) + module.exit_json(**camel_dict_to_snake_dict(result)) if __name__ == "__main__": diff --git a/tests/integration/targets/backup_selection/tasks/main.yml b/tests/integration/targets/backup_selection/tasks/main.yml index 98ac62bc2c5..c29d738b3c3 100644 --- a/tests/integration/targets/backup_selection/tasks/main.yml +++ b/tests/integration/targets/backup_selection/tasks/main.yml @@ -139,6 +139,12 @@ ansible.builtin.assert: that: - _result_backup_selection_info.backup_selections | length == 1 + - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn + - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - "'resources' in _result_backup_selection_info.backup_selections[0]" + - "'not_resources' in _result_backup_selection_info.backup_selections[0]" + - "'list_of_tags' in _result_backup_selection_info.backup_selections[0]" + - "'conditions' in _result_backup_selection_info.backup_selections[0]" - name: Modify an AWS Backup selection (check_mode) amazon.aws.backup_selection: