Skip to content

Chore: [AEA-6593] - move to new exports#3025

Merged
anthony-nhs merged 5 commits intomainfrom
move_to_new_imports
May 1, 2026
Merged

Chore: [AEA-6593] - move to new exports#3025
anthony-nhs merged 5 commits intomainfrom
move_to_new_imports

Conversation

@anthony-nhs
Copy link
Copy Markdown
Contributor

@anthony-nhs anthony-nhs commented Apr 28, 2026

Summary

  • Routine Change

Details

  • move to new exports
  • use latest regression tests

Copilot AI review requested due to automatic review settings April 28, 2026 17:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates infrastructure templates and CI/CD scripts to consume the new CloudFormation export names (primarily moving from legacy account-resources / lambda-resources exports to CDK-provided exports).

Changes:

  • Updated SAM templates to import KMS, Splunk, Secrets and related IAM policy ARNs from the new export namespaces.
  • Updated alarms to use the new Slack SNS topic export.
  • Updated release/deploy automation to look up the new export names (including adding jq-based export selection in the release workflow).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
SAMtemplates/state_machines/state_machine_resources.yaml Switch state machine role managed policy import to new CloudWatch encryption KMS policy export.
SAMtemplates/state_machines/main.yaml Update KMS key + Splunk role/stream imports to new export names for state machines.
SAMtemplates/sandbox_template.yaml Update KMS/Splunk imports and secrets access policy import to new export names.
SAMtemplates/functions/main.yaml Update KMS/Splunk imports and secrets access policy import to new export names for Lambda apps.
SAMtemplates/functions/lambda_resources.yaml Update managed policy imports (Insights, CW encryption, secrets decrypt) to new export names.
SAMtemplates/apis/main.yaml Update truststore bucket import to new export name used to build the S3 truststore URI.
SAMtemplates/apis/api_resources.yaml Update API Gateway log group KMS key + Splunk role/stream imports to new export names.
SAMtemplates/alarms/main.yaml Update Slack SNS topic imports to new export name.
.github/workflows/run_release_code_and_api.yml Update workflow to fetch mTLS secret ARNs via new export names using jq.
.github/scripts/release_code.sh Update export lookups for artifact bucket / execution role / truststore bucket to new export names.
.github/scripts/deploy_api.sh Update proxygen private key export lookup to new export name.
.github/scripts/delete_proxygen_deployments.sh Update proxygen private key export lookup to new export name.

Comment thread .github/scripts/release_code.sh Outdated
Comment on lines +9 to +12
artifact_bucket=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

artifact_bucket is now set to the CloudFormation export value for ...:ArtifactsBucket:Arn, but it’s passed to sam deploy --s3-bucket, which expects an S3 bucket name (not an ARN). This will cause sam deploy to fail. Parse the bucket name from the ARN (as was done previously) or change the export used here to one that returns the bucket name.

Suggested change
artifact_bucket=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
ARTIFACT_BUCKET_ARN=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
artifact_bucket=$(echo "${ARTIFACT_BUCKET_ARN}" | cut -d ":" -f 6)
if [ -z "${artifact_bucket}" ]; then
echo "could not retrieve artifact bucket name from aws cloudformation list-exports"
exit 1
fi

Copilot uses AI. Check for mistakes.
client_cert_arn=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "secrets-cdk:Secrets:PsuClientCertSecret:Arn" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These jq selections will return an empty string if the export name isn’t found, and the subsequent aws secretsmanager get-secret-value will fail with a confusing error (invalid/empty secret id). Add explicit checks that client_private_key_arn and client_cert_arn are non-empty and fail early with a clear message if the exports are missing.

Suggested change
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
if [[ -z "${client_private_key_arn}" ]]; then
echo "Error: required CloudFormation export 'secrets-cdk:Secrets:PsuClientKeySecret:Arn' was not found in eu-west-2." >&2
exit 1
fi
if [[ -z "${client_cert_arn}" ]]; then
echo "Error: required CloudFormation export 'secrets-cdk:Secrets:PsuClientCertSecret:Arn' was not found in eu-west-2." >&2
exit 1
fi

Copilot uses AI. Check for mistakes.
# Retrieve the proxygen private key and client private key and cert from AWS Secrets Manager
proxygen_private_key_arn=$(aws cloudformation list-exports --query "Exports[?Name=='account-resources:${PROXYGEN_PRIVATE_KEY_NAME}'].Value" --output text)
proxygen_private_key_arn=$(aws cloudformation list-exports --query "Exports[?Name=='secrets-cdk:Secrets:${PROXYGEN_PRIVATE_KEY_NAME}:Arn'].Value" --output text)

Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the CloudFormation export isn’t present, this list-exports query will return an empty string and later payloads will use an invalid proxygenSecretName. Add a check after this assignment to ensure proxygen_private_key_arn is non-empty and exit with a clear error if it can’t be resolved.

Suggested change
if [[ -z "${proxygen_private_key_arn}" || "${proxygen_private_key_arn}" == "None" ]]; then
echo "Error: Could not resolve CloudFormation export 'secrets-cdk:Secrets:${PROXYGEN_PRIVATE_KEY_NAME}:Arn' for PROXYGEN_PRIVATE_KEY_NAME='${PROXYGEN_PRIVATE_KEY_NAME}'." >&2
exit 1
fi

Copilot uses AI. Check for mistakes.
proxygen_private_key_arn=$(aws cloudformation list-exports --query "Exports[?Name=='account-resources:${PROXYGEN_PRIVATE_KEY_NAME}'].Value" --output text)

proxygen_private_key_arn=$(aws cloudformation list-exports --query "Exports[?Name=='secrets-cdk:Secrets:${PROXYGEN_PRIVATE_KEY_NAME}:Arn'].Value" --output text)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the CloudFormation export isn’t present, this list-exports query will return an empty string and the subsequent Lambda payloads will be built with an invalid proxygenSecretName. Add a check after this assignment to ensure proxygen_private_key_arn is non-empty and exit with a clear error if it can’t be resolved.

Suggested change
if [ -z "${proxygen_private_key_arn}" ]; then
echo "Error: Unable to resolve CloudFormation export secrets-cdk:Secrets:${PROXYGEN_PRIVATE_KEY_NAME}:Arn for ${APIGEE_ENVIRONMENT}. Cannot continue without a valid proxygen private key ARN."
exit 1
fi

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 2026

@anthony-nhs anthony-nhs merged commit 3011d7b into main May 1, 2026
17 checks passed
@anthony-nhs anthony-nhs deleted the move_to_new_imports branch May 1, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants