Skip to content

Commit

Permalink
Added state_machine_arn when unchanged. (ansible-collections#302)
Browse files Browse the repository at this point in the history
* Added state_machine_arn when unchanged.
* Add integration test
* changelog
* Shorten role/function names in integration tests

Co-authored-by: Mark Chappell <[email protected]>
  • Loading branch information
ThePrankMonkey and tremble authored Mar 16, 2021
1 parent 6c1626e commit 528bdb5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 1 addition & 1 deletion plugins/modules/aws_step_functions_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 528bdb5

Please sign in to comment.