@@ -436,10 +436,10 @@ jobs:
436436 - name : Get State Machine ARN
437437 id : get_sm_arn
438438 run : |
439- # Get test state machine ARN
440- ARN=$(aws stepfunctions describe-state-machine \
441- --state-machine-arn "arn:aws:states:${{ env.AWS_REGION }}:$(aws sts get-caller-identity --query Account --output text):stateMachine:nrds_test_sm " \
442- --query 'stateMachineArn ' \
439+ # Get state machine ARN from SSM parameter (set by Terraform)
440+ ARN=$(aws ssm get-parameter \
441+ --name "/datastream/ state-machine-arn" \
442+ --query 'Parameter.Value ' \
443443 --output text \
444444 --region ${{ env.AWS_REGION }})
445445 echo "arn=$ARN" >> "$GITHUB_OUTPUT"
@@ -724,7 +724,7 @@ jobs:
724724 name : Terraform Destroy Test Resources
725725 needs : [test-short-range-vpus]
726726 runs-on : ubuntu-latest
727- if : success () # Only destroy on success, leave resources for debugging on failure
727+ if : always () # Always cleanup resources, even on failure
728728 defaults :
729729 run :
730730 working-directory : infra/aws/terraform
@@ -800,12 +800,15 @@ jobs:
800800 run : |
801801 echo "Stopping test Step Functions executions..."
802802
803- # Use test state machine
804- AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
805- STATE_MACHINE_ARN="arn:aws:states:${{ env.AWS_REGION }}:${AWS_ACCOUNT_ID}:stateMachine:nrds_test_sm"
803+ # Get state machine ARN from SSM parameter (set by Terraform)
804+ STATE_MACHINE_ARN=$(aws ssm get-parameter \
805+ --name "/datastream/state-machine-arn" \
806+ --query 'Parameter.Value' \
807+ --output text \
808+ --region ${{ env.AWS_REGION }} 2>/dev/null) || true
806809
807810 # Check if state machine exists
808- if aws stepfunctions describe-state-machine --state-machine-arn "$STATE_MACHINE_ARN" --region ${{ env.AWS_REGION }} >/dev/null 2>&1; then
811+ if [ -n "$STATE_MACHINE_ARN" ] && aws stepfunctions describe-state-machine --state-machine-arn "$STATE_MACHINE_ARN" --region ${{ env.AWS_REGION }} >/dev/null 2>&1; then
809812 # Stop all running executions matching test pattern (sr=short_range, mr=medium_range, aae=analysis_assim_extend)
810813 aws stepfunctions list-executions \
811814 --state-machine-arn "$STATE_MACHINE_ARN" \
0 commit comments