From 528bdb529ae04b46bc06d7ba9b4e94297223266d Mon Sep 17 00:00:00 2001 From: Matthew Hellmer Date: Tue, 16 Mar 2021 06:57:26 -0400 Subject: [PATCH] Added state_machine_arn when unchanged. (#302) * Added state_machine_arn when unchanged. * Add integration test * changelog * Shorten role/function names in integration tests Co-authored-by: Mark Chappell --- .../302-aws_step_functions_state_machine-ARN-not-change.yml | 2 ++ plugins/modules/aws_step_functions_state_machine.py | 2 +- .../aws_step_functions_state_machine/defaults/main.yml | 4 ++-- .../targets/aws_step_functions_state_machine/tasks/main.yml | 6 ++++-- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 changelogs/302-aws_step_functions_state_machine-ARN-not-change.yml diff --git a/changelogs/302-aws_step_functions_state_machine-ARN-not-change.yml b/changelogs/302-aws_step_functions_state_machine-ARN-not-change.yml new file mode 100644 index 00000000000..2305eb95852 --- /dev/null +++ b/changelogs/302-aws_step_functions_state_machine-ARN-not-change.yml @@ -0,0 +1,2 @@ +minor_changes: +- state_machine_arn - return ``state_machine_arn`` when state is unchanged (https://github.com/ansible-collections/community.aws/pull/302). diff --git a/plugins/modules/aws_step_functions_state_machine.py b/plugins/modules/aws_step_functions_state_machine.py index 5ab13baa76c..be9d594d7c2 100644 --- a/plugins/modules/aws_step_functions_state_machine.py +++ b/plugins/modules/aws_step_functions_state_machine.py @@ -123,7 +123,7 @@ def manage_state_machine(state, sfn_client, module): remove(state_machine_arn, sfn_client, module) check_mode(module, msg='State is up-to-date.') - module.exit_json(changed=False) + module.exit_json(changed=False, state_machine_arn=state_machine_arn) def create(sfn_client, module): diff --git a/tests/integration/targets/aws_step_functions_state_machine/defaults/main.yml b/tests/integration/targets/aws_step_functions_state_machine/defaults/main.yml index 273a0c783b8..d3dea56cd72 100644 --- a/tests/integration/targets/aws_step_functions_state_machine/defaults/main.yml +++ b/tests/integration/targets/aws_step_functions_state_machine/defaults/main.yml @@ -1,4 +1,4 @@ # the random_num is generated in a set_fact task at the start of the testsuite -state_machine_name: "{{ resource_prefix }}_step_functions_state_machine_ansible_test_{{ random_num }}" -step_functions_role_name: "ansible-test-sts-{{ resource_prefix }}-step_functions-role" +state_machine_name: "{{ resource_prefix }}_step_function_{{ random_num }}" +step_functions_role_name: "ansible-test-{{ resource_prefix }}-step-function" execution_name: "{{ resource_prefix }}_sfn_execution" diff --git a/tests/integration/targets/aws_step_functions_state_machine/tasks/main.yml b/tests/integration/targets/aws_step_functions_state_machine/tasks/main.yml index 005af35f73f..8c4bbec716d 100644 --- a/tests/integration/targets/aws_step_functions_state_machine/tasks/main.yml +++ b/tests/integration/targets/aws_step_functions_state_machine/tasks/main.yml @@ -26,12 +26,12 @@ pause: seconds: 10 - # ==== Tests =================================================== - - name: Create a random component for state machine name set_fact: random_num: "{{ 999999999 | random }}" + # ==== Tests =================================================== + - name: Create a new state machine -- check_mode aws_step_functions_state_machine: name: "{{ state_machine_name }}" @@ -61,6 +61,7 @@ - assert: that: - creation_output.changed == True + - '"state_machine_arn" in creation_output' - name: Pause a few seconds to ensure state machine role is available pause: @@ -95,6 +96,7 @@ - assert: that: - result.changed == False + - result.state_machine_arn == creation_output.state_machine_arn - name: Update an existing state machine -- check_mode aws_step_functions_state_machine: