-
Notifications
You must be signed in to change notification settings - Fork 1
Build: [AEA-0000] - Add retry logic to the deploy-api stage #2986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,33 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -eu pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| invoke_lambda_with_retry() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local function_name="$1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local payload_file="$2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local max_attempts=3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local delay=30 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for attempt in $(seq 1 "$max_attempts"); do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Invoking ${function_name} (attempt ${attempt} of ${max_attempts})" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aws lambda invoke --function-name "${function_name}" --cli-binary-format raw-in-base64-out --payload "file://${payload_file}" out.txt > response.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ! eval "cat response.json | jq -e '.FunctionError' >/dev/null"; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Error calling lambda (attempt ${attempt} of ${max_attempts})" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cat out.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+19
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for attempt in $(seq 1 "$max_attempts"); do | |
| echo "Invoking ${function_name} (attempt ${attempt} of ${max_attempts})" | |
| aws lambda invoke --function-name "${function_name}" --cli-binary-format raw-in-base64-out --payload "file://${payload_file}" out.txt > response.json | |
| if ! eval "cat response.json | jq -e '.FunctionError' >/dev/null"; then | |
| return 0 | |
| fi | |
| echo "Error calling lambda (attempt ${attempt} of ${max_attempts})" | |
| cat out.txt | |
| local safe_function_name | |
| safe_function_name=$(printf '%s' "${function_name}" | tr -c '[:alnum:]._-' '_') | |
| for attempt in $(seq 1 "$max_attempts"); do | |
| local payload_output_file="${safe_function_name}.attempt_${attempt}.out.txt" | |
| local invoke_metadata_file="${safe_function_name}.attempt_${attempt}.response.json" | |
| echo "Invoking ${function_name} (attempt ${attempt} of ${max_attempts})" | |
| aws lambda invoke --function-name "${function_name}" --cli-binary-format raw-in-base64-out --payload "file://${payload_file}" "${payload_output_file}" > "${invoke_metadata_file}" | |
| if ! jq -e '.FunctionError' "${invoke_metadata_file}" >/dev/null; then | |
| return 0 | |
| fi | |
| echo "Error calling lambda (attempt ${attempt} of ${max_attempts})" | |
| echo "Lambda payload output (${payload_output_file}):" | |
| cat "${payload_output_file}" | |
| echo "Lambda invoke metadata (${invoke_metadata_file}):" | |
| cat "${invoke_metadata_file}" |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jq payload object contains kid, $kid, which is not valid key/value construction and will either set kid to null or cause a jq syntax error. This should be a proper field assignment (e.g. kid: $kid) so the lambda receives the expected KID value.
| '{apiName: $apiName, environment: $environment, secretName: $secretName, secretKey: $secretKey, secretCert: $secretCert, kid, $kid, proxygenSecretName: $proxygenSecretName}' > payload.json | |
| '{apiName: $apiName, environment: $environment, secretName: $secretName, secretKey: $secretKey, secretCert: $secretCert, kid: $kid, proxygenSecretName: $proxygenSecretName}' > payload.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
god damn, that might be the problem. Why does this work most of the time, then?
Uh oh!
There was an error while loading. Please reload this page.