@@ -77,7 +77,7 @@ cleanup_resources() {
7777
7878 if [ -n " ${FLOW_ARN:- } " ]; then
7979 # Security: Validate ARN format before using it
80- if [[ ! " $FLOW_ARN " =~ ^arn:aws:mediaconnect:[a-z0-9-]+:[0-9]+:flow:[a-zA-Z0-9-]+$ ]]; then
80+ if [[ ! " $FLOW_ARN " =~ ^arn:aws:mediaconnect:[a-z0-9-]+:[0-9]+:flow:[a-zA-Z0-9: -]+$ ]]; then
8181 echo " WARNING: Invalid Flow ARN format, skipping cleanup: $FLOW_ARN "
8282 return 1
8383 fi
@@ -192,14 +192,17 @@ else
192192fi
193193
194194# Extract the flow ARN from the output
195- FLOW_ARN=$( extract_json_value " $create_flow_output " " FlowArn" )
195+ FLOW_ARN=$( echo " $create_flow_output " | jq -r ' .Flow.FlowArn // empty' 2> /dev/null)
196+ if [ -z " $FLOW_ARN " ]; then
197+ FLOW_ARN=$( echo " $create_flow_output " | grep -o ' "FlowArn": "[^"]*' | head -1 | cut -d' "' -f4)
198+ fi
196199if [ -z " $FLOW_ARN " ]; then
197200 handle_error " Failed to extract flow ARN from output"
198201fi
199202echo " Flow ARN: $FLOW_ARN "
200203
201204# Validate flow ARN format
202- if [[ ! " $FLOW_ARN " =~ ^arn:aws:mediaconnect:[a-z0-9-]+:[0-9]+:flow:[a-zA-Z0-9-]+$ ]]; then
205+ if [[ ! " $FLOW_ARN " =~ ^arn:aws:mediaconnect:[a-z0-9-]+:[0-9]+:flow:[a-zA-Z0-9: -]+$ ]]; then
203206 handle_error " Invalid Flow ARN format: $FLOW_ARN "
204207fi
205208
216219
217220# Extract the output ARN
218221output_arn=" "
219- output_arn=$( extract_json_value " $add_output_output " " OutputArn" )
222+ output_arn=$( echo " $add_output_output " | jq -r " .Output.OutputArn // empty" 2> /dev/null)
223+ if [ -z " $output_arn " ]; then output_arn=$( echo " $add_output_output " | grep -o ' "OutputArn": "[^"]*' | head -1 | cut -d' "' -f4) ; fi
220224if [ -z " $output_arn " ]; then
221225 echo " WARNING: Failed to extract output ARN from output"
222226else
237241
238242# Extract the entitlement ARN
239243entitlement_arn=" "
240- entitlement_arn=$( extract_json_value " $grant_entitlement_output " " EntitlementArn" )
244+ entitlement_arn=$( echo " $grant_entitlement_output " | jq -r ' .Entitlement.EntitlementArn // empty' 2> /dev/null)
245+ if [ -z " $entitlement_arn " ]; then
246+ entitlement_arn=$( echo " $grant_entitlement_output " | grep -o ' "EntitlementArn": "[^"]*' | head -1 | cut -d' "' -f4)
247+ fi
241248if [ -z " $entitlement_arn " ]; then
242249 echo " WARNING: Failed to extract entitlement ARN from output"
243250else
0 commit comments