diff --git a/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml b/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml index 2f2b0758eb..8b56cb2ca5 100644 --- a/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml +++ b/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml @@ -515,14 +515,21 @@ ansible.builtin.wait_for: timeout: 45 + - name: Fetch updated state of key + amazon.aws.kms_key_info: + alias: "{{ kms_key_alias }}" + pending_deletion: True + register: deleted_kms + - name: Assert that state is pending deletion vars: + deleted_key: '{{ deleted_kms.kms_keys[0] }}' now_time: '{{ lookup("pipe", "date -u +%Y-%m-%d\ %H:%M:%S") }}' - deletion_time: '{{ delete_kms.deletion_date[:19] | to_datetime("%Y-%m-%dT%H:%M:%S") }}' + deletion_time: '{{ deleted_key.deletion_date[:19] | to_datetime("%Y-%m-%dT%H:%M:%S") }}' ansible.builtin.assert: that: - - delete_kms.key_state == "PendingDeletion" - delete_kms.changed + - deleted_key.key_state == "PendingDeletion" # Times won't be perfect, allow a 24 hour window - (( deletion_time | to_datetime ) - ( now_time | to_datetime )).days <= 7 - (( deletion_time | to_datetime ) - ( now_time | to_datetime )).days >= 6