Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/create_changeset_existing_tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi

ROLE=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "ci-resources:CloudFormationExecutionRole" \
--arg EXPORT_NAME "iam-cdk:IAM:CloudFormationExecutionRole:Arn" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')

if [ -z "${ROLE}" ]; then
Expand All @@ -34,6 +34,7 @@ if [ "${status}" != '"CREATE_COMPLETE"' ] && [ "${status}" != '"UPDATE_ROLLBACK_
fi

# upload file to s3
# change this to account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn once other change is merged
artifact_bucket_arn=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "account-resources:ArtifactsBucket" \
Expand Down
3 changes: 2 additions & 1 deletion .github/scripts/create_changeset_new_tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CF_LONDON_EXPORTS=$(aws cloudformation list-exports --region eu-west-2 --output

ROLE=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "ci-resources:CloudFormationExecutionRole" \
--arg EXPORT_NAME "iam-cdk:IAM:CloudFormationExecutionRole:Arn" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
if [ -z "${ROLE}" ]; then
echo "could not retrieve ROLE from aws cloudformation list-exports"
Expand All @@ -27,6 +27,7 @@ if [ "${status}" != '"CREATE_COMPLETE"' ] && [ "${status}" != '"UPDATE_ROLLBACK_
fi

# upload file to s3
# change this to account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn once other change is merged
artifact_bucket_arn=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "account-resources:ArtifactsBucket" \
Expand Down
1 change: 1 addition & 0 deletions .github/scripts/execute_changeset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AWS_MAX_ATTEMPTS=20
export AWS_MAX_ATTEMPTS

CF_LONDON_EXPORTS=$(aws cloudformation list-exports --region eu-west-2 --output json)
# change this to account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn once other change is merged
artifact_bucket_arn=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "account-resources:ArtifactsBucket" \
Expand Down
13 changes: 11 additions & 2 deletions .github/scripts/release_code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ echo "$COMMIT_ID"
AWS_MAX_ATTEMPTS=10
export AWS_MAX_ATTEMPTS

artifact_bucket=$(aws cloudformation list-exports --output json | jq -r '.Exports[] | select(.Name == "account-resources:ArtifactsBucket") | .Value' | grep -o '[^:]*$')
CF_LONDON_EXPORTS=$(aws cloudformation list-exports --region eu-west-2 --output json)
# change this to account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn once other change is merged
artifact_bucket_arn=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "account-resources:ArtifactsBucket" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
artifact_bucket=$(echo "$artifact_bucket_arn" | cut -d: -f6 | cut -d/ -f1)
if [ -z "${artifact_bucket}" ]; then
Comment on lines +11 to 16
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

jq -r returns the literal string null when the export name is not found, and the current -z check won’t catch that. Add a guard that also treats null (and ideally non-ARN values) as failure before deriving the bucket name, otherwise the script can proceed with an invalid bucket and fail later in less obvious ways.

Copilot uses AI. Check for mistakes.
echo "could not retrieve artifact_bucket from aws cloudformation list-exports"
exit 1
fi
export artifact_bucket

cloud_formation_execution_role=$(aws cloudformation list-exports --output json | jq -r '.Exports[] | select(.Name == "ci-resources:CloudFormationExecutionRole") | .Value' )
cloud_formation_execution_role=$(echo "$CF_LONDON_EXPORTS" | \
jq \
--arg EXPORT_NAME "iam-cdk:IAM:CloudFormationExecutionRole:Arn" \
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
if [ -z "${cloud_formation_execution_role}" ]; then
Comment on lines +22 to 26
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

Similarly, if the CloudFormation execution role export is missing, jq -r will yield null and the -z check won’t fail. Treat null as an error (and optionally validate it looks like an IAM role ARN) so sam deploy --role-arn isn’t invoked with an invalid value.

Copilot uses AI. Check for mistakes.
echo "could not retrieve cloud_formation_execution_role from aws cloudformation list-exports"
exit 1
Expand Down
6 changes: 3 additions & 3 deletions SAMtemplates/common_lambda_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ Resources:
- !Join
- ","
- - !Ref LambdaManagedPolicy
- !ImportValue lambda-resources:LambdaInsightsLogGroupPolicy
- !ImportValue account-resources:LambdaEncryptCloudwatchKMSPolicy
- !ImportValue account-resources:LambdaDecryptSecretsKMSPolicy
- !ImportValue account-resources-cdk-uk:IAM:LambdaInsightsLogGroupPolicy:Arn
- !ImportValue account-resources-cdk-uk:IAM:LambdaEncryptCloudwatchKMSPolicy:Arn
- !ImportValue secrets-cdk:IAM:LambdaDecryptSecretsKMSPolicy:Arn
- !If
- ShouldIncludeAdditionalPolicies
- !Join
Expand Down
28 changes: 14 additions & 14 deletions cloudformation/account_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Resources:
Effect: Allow
Principal:
AWS:
- !ImportValue ci-resources:CloudFormationExecutionRole
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Arn
- !Sub arn:aws:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-west-2
Action:
- kms:DescribeKey
Expand Down Expand Up @@ -255,9 +255,9 @@ Resources:
Type: AWS::IAM::ManagedPolicy
Properties:
Roles:
- !ImportValue ci-resources:CloudFormationExecutionRoleName
- !ImportValue ci-resources:CloudFormationPrepareChangesetRoleName
- !ImportValue ci-resources:CloudFormationDeployRoleName
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Name
- !ImportValue iam-cdk:IAM:CloudFormationPrepareChangesetRole:Name
- !ImportValue iam-cdk:IAM:CloudFormationDeployRole:Name
PolicyDocument:
Version: 2012-10-17
Statement:
Expand Down Expand Up @@ -326,9 +326,9 @@ Resources:
- Effect: Allow
Principal:
AWS:
- !ImportValue ci-resources:CloudFormationDeployRole
- !ImportValue ci-resources:CloudFormationExecutionRole
- !ImportValue ci-resources:CloudFormationPrepareChangesetRole
- !ImportValue iam-cdk:IAM:CloudFormationDeployRole:Arn
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Arn
- !ImportValue iam-cdk:IAM:CloudFormationPrepareChangesetRole:Arn
Action:
- s3:GetObject*
- s3:PutObject*
Expand All @@ -340,7 +340,7 @@ Resources:
- Effect: Allow
Principal:
AWS:
- !ImportValue ci-resources:CloudFormationDeployRole
- !ImportValue ciam-cdk:IAM:CloudFormationDeployRole:Arn
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The import name ciam-cdk:IAM:CloudFormationDeployRole:Arn looks like a typo (note ciam-cdk vs iam-cdk) and will cause Fn::ImportValue to fail at deploy time, breaking the bucket policy update. Use the correct export name for the CloudFormation deploy role ARN here.

Suggested change
- !ImportValue ciam-cdk:IAM:CloudFormationDeployRole:Arn
- !ImportValue iam-cdk:IAM:CloudFormationDeployRole:Arn

Copilot uses AI. Check for mistakes.
Action:
- s3:DeleteObject*
Resource:
Expand Down Expand Up @@ -374,7 +374,7 @@ Resources:
Type: AWS::IAM::ManagedPolicy
Properties:
Roles:
- !ImportValue ci-resources:CloudFormationExecutionRoleName
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Name
PolicyDocument:
Version: 2012-10-17
Statement:
Expand Down Expand Up @@ -434,8 +434,8 @@ Resources:
- Effect: Allow
Principal:
AWS:
- !ImportValue ci-resources:CloudFormationDeployRole
- !ImportValue ci-resources:CloudFormationExecutionRole
- !ImportValue iam-cdk:IAM:CloudFormationDeployRole:Arn
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Arn
- !Sub arn:aws:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-eu-west-2
Action:
- s3:GetObject*
Expand Down Expand Up @@ -1134,7 +1134,7 @@ Resources:
Type: AWS::IAM::ManagedPolicy
Properties:
Roles:
- !ImportValue ci-resources:CloudFormationExecutionRoleName
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Name
PolicyDocument:
Version: 2012-10-17
Statement:
Expand Down Expand Up @@ -1207,7 +1207,7 @@ Resources:
Type: AWS::IAM::ManagedPolicy
Properties:
Roles:
- !ImportValue ci-resources:CloudFormationExecutionRoleName
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Name
PolicyDocument:
Version: 2012-10-17
Statement:
Expand Down Expand Up @@ -1271,7 +1271,7 @@ Resources:
Type: AWS::IAM::ManagedPolicy
Properties:
Roles:
- !ImportValue ci-resources:CloudFormationExecutionRoleName
- !ImportValue iam-cdk:IAM:CloudFormationExecutionRole:Name
PolicyDocument:
Version: 2012-10-17
Statement:
Expand Down
6 changes: 3 additions & 3 deletions cloudformation/artillery_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Resources:
DestinationBucketName:
!Select [
5,
!Split [":", !ImportValue account-resources:AuditLoggingBucket],
!Split [":", !ImportValue account-resources-cdk-uk:Bucket:AuditLoggingBucket:Arn],
]
LogFilePrefix: artilleryIO/
VersioningConfiguration:
Expand Down Expand Up @@ -126,7 +126,7 @@ Resources:
- ","
- !Join
- ","
- - !ImportValue account-resources:CloudwatchEncryptionKMSPolicyArn
- - !ImportValue account-resources-cdk-uk:IAM:CloudwatchEncryptionKMSPolicy:Arn

ArtilleryWorkerPolicy:
Type: AWS::IAM::ManagedPolicy
Expand Down Expand Up @@ -194,7 +194,7 @@ Resources:
Properties:
LogGroupName: artilleryio-log-group/artilleryio-cluster
RetentionInDays: 30
KmsKeyId: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
KmsKeyId: !ImportValue account-resources-cdk-uk:KMS:CloudwatchLogsKmsKey:Arn

ECSCluster:
Type: "AWS::ECS::Cluster"
Expand Down
56 changes: 28 additions & 28 deletions cloudformation/ci_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,34 +149,34 @@ Resources:
Action:
- secretsmanager:GetSecretValue
Resource:
- !ImportValue account-resources:PfpClientKeySecret
- !ImportValue account-resources:PfpClientCertSecret
- !ImportValue account-resources:PfpClientSandboxKeySecret
- !ImportValue account-resources:PfpClientSandboxCertSecret
- !ImportValue account-resources:PsuClientKeySecret
- !ImportValue account-resources:PsuClientSandboxKeySecret
- !ImportValue account-resources:PsuCACertSecret
- !ImportValue account-resources:PsuCAKeySecret
- !ImportValue account-resources:PsuClientCertSecret
- !ImportValue account-resources:PsuClientSandboxCertSecret
- !ImportValue account-resources:PSUProxygenPrivateKey
- !ImportValue account-resources:PSUProxygenPublicKey
- !ImportValue account-resources:CPSUProxygenPrivateKey
- !ImportValue account-resources:CPSUProxygenPublicKey
- !ImportValue account-resources:ClinicalTrackerClientKeySecret
- !ImportValue account-resources:ClinicalTrackerClientSandboxKeySecret
- !ImportValue account-resources:ClinicalTrackerCACertSecret
- !ImportValue account-resources:ClinicalTrackerCAKeySecret
- !ImportValue account-resources:ClinicalTrackerClientCertSecret
- !ImportValue account-resources:ClinicalTrackerClientSandboxCertSecret
- !ImportValue account-resources:ClinicalTrackerProxygenPrivateKey
- !ImportValue account-resources:ClinicalTrackerProxygenPublicKey
- !ImportValue account-resources:FhirFacadeClientKeySecret
- !ImportValue account-resources:FhirFacadeClientSandboxKeySecret
- !ImportValue account-resources:FhirFacadeCACertSecret
- !ImportValue account-resources:FhirFacadeCAKeySecret
- !ImportValue account-resources:FhirFacadeClientCertSecret
- !ImportValue account-resources:FhirFacadeClientSandboxCertSecret
- !ImportValue secrets-cdk:Secrets:PfpClientKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:PfpClientSandboxCertSecret:Arn
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

This secret ARN allowlist has become inconsistent with the previous set: PfpClientCertSecret is no longer included, and PfpClientSandboxCertSecret is duplicated. This will either remove required access (if the cert secret is still needed) and/or add redundant entries; update the list to include each intended secret exactly once.

Suggested change
- !ImportValue secrets-cdk:Secrets:PfpClientSandboxCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:PfpClientCertSecret:Arn

Copilot uses AI. Check for mistakes.
- !ImportValue secrets-cdk:Secrets:PfpClientSandboxKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:PfpClientSandboxCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:PsuClientKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:PsuClientSandboxCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:PsuCACertSecret:Arn
- !ImportValue secrets-cdk:Secrets:PsuCAKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:PsuClientCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:PsuClientSandboxCertSecret:Arn
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The PSU sandbox secret imports appear incorrect: PsuClientSandboxKeySecret is missing, while PsuClientSandboxCertSecret is listed twice. This will grant permissions to the wrong set of secrets and may break workflows that expect access to the sandbox key secret.

Suggested change
- !ImportValue secrets-cdk:Secrets:PsuClientSandboxCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:PsuClientSandboxKeySecret:Arn

Copilot uses AI. Check for mistakes.
- !ImportValue secrets-cdk:Secrets:PSUProxygenPrivateKey:Arn
- !ImportValue secrets-cdk:Secrets:PSUProxygenPublicKey:Arn
- !ImportValue secrets-cdk:Secrets:CPSUProxygenPrivateKey:Arn
- !ImportValue secrets-cdk:Secrets:CPSUProxygenPublicKey:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerClientKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerClientSandboxKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerCACertSecret:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerCAKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerClientCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerClientSandboxCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerProxygenPrivateKey:Arn
- !ImportValue secrets-cdk:Secrets:ClinicalTrackerProxygenPublicKey:Arn
- !ImportValue secrets-cdk:Secrets:FhirFacadeClientKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:FhirFacadeClientSandboxKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:FhirFacadeCACertSecret:Arn
- !ImportValue secrets-cdk:Secrets:FhirFacadeCAKeySecret:Arn
- !ImportValue secrets-cdk:Secrets:FhirFacadeClientCertSecret:Arn
- !ImportValue secrets-cdk:Secrets:FhirFacadeClientSandboxCertSecret:Arn
- Effect: Allow
Action:
- kms:Decrypt
Expand Down
6 changes: 3 additions & 3 deletions cloudformation/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Resources:
Type: AWS::SecretsManager::Secret
Properties:
Description: Private key for prescribing proxygen
KmsKeyId: !ImportValue account-resources:SecretsKMSKeyAlias
KmsKeyId: !ImportValue secrets-cdk:KMS:SecretsKMSKeyAlias:Arn
SecretString: ChangeMe
Name: !Sub "${AWS::StackName}-Prescribing-ProxygenPrivateKey"

Expand All @@ -29,7 +29,7 @@ Resources:
Type: AWS::SecretsManager::Secret
Properties:
Description: Private key for prescribing proxygen prod
KmsKeyId: !ImportValue account-resources:SecretsKMSKeyAlias
KmsKeyId: !ImportValue secrets-cdk:KMS:SecretsKMSKeyAlias:Arn
SecretString: ChangeMe
Name: "FhirPrescribingProxygen-PrivateKey-prod"

Expand All @@ -53,7 +53,7 @@ Resources:
Type: AWS::SecretsManager::Secret
Properties:
Description: Private key for prescribing proxygen ptl
KmsKeyId: !ImportValue account-resources:SecretsKMSKeyAlias
KmsKeyId: !ImportValue secrets-cdk:KMS:SecretsKMSKeyAlias:Arn
SecretString: ChangeMe
Name: "FhirPrescribingProxygen-PrivateKey-ptl"

Expand Down