Skip to content

Commit 3313e7b

Browse files
authored
Chore: [AEA-6593] - use new exports (#519)
## Summary - Routine Change ### Details - use exports from cdk stack
1 parent 5d9767d commit 3313e7b

4 files changed

Lines changed: 39 additions & 16 deletions

File tree

.github/scripts/release_code.sh

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
#!/usr/bin/env bash
22

33
echo "$COMMIT_ID"
4+
CF_LONDON_EXPORTS=$(aws cloudformation list-exports --region eu-west-2 --output json)
5+
ARTIFACT_BUCKET_ARN=$(echo "$CF_LONDON_EXPORTS" | \
6+
jq \
7+
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn" \
8+
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
9+
ARTIFACT_BUCKET_NAME=$(echo "$ARTIFACT_BUCKET_ARN" | cut -d: -f6 | cut -d/ -f1)
10+
if [ -z "${ARTIFACT_BUCKET_NAME}" ]; then
11+
echo "could not retrieve artifact_bucket from aws cloudformation list-exports"
12+
exit 1
13+
fi
414

5-
artifact_bucket=$(aws cloudformation list-exports --output json | jq -r '.Exports[] | select(.Name == "account-resources:ArtifactsBucket") | .Value' | grep -o '[^:]*$')
6-
export artifact_bucket
7-
8-
cloud_formation_execution_role=$(aws cloudformation list-exports --output json | jq -r '.Exports[] | select(.Name == "ci-resources:CloudFormationExecutionRole") | .Value' )
9-
export cloud_formation_execution_role
15+
CLOUD_FORMATION_EXECUTION_ROLE=$(echo "$CF_LONDON_EXPORTS" | \
16+
jq \
17+
--arg EXPORT_NAME "iam-cdk:IAM:CloudFormationExecutionRole:Arn" \
18+
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
19+
if [ -z "${CLOUD_FORMATION_EXECUTION_ROLE}" ]; then
20+
echo "could not retrieve cloud_formation_execution_role from aws cloudformation list-exports"
21+
exit 1
22+
fi
1023

11-
TRUSTSTORE_BUCKET_ARN=$(aws cloudformation describe-stacks --stack-name account-resources --query "Stacks[0].Outputs[?OutputKey=='TrustStoreBucket'].OutputValue" --output text)
24+
TRUSTSTORE_BUCKET_ARN=$(echo "$CF_LONDON_EXPORTS" | \
25+
jq \
26+
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:TrustStoreBucket:Arn" \
27+
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
1228
TRUSTSTORE_BUCKET_NAME=$(echo "${TRUSTSTORE_BUCKET_ARN}" | cut -d ":" -f 6)
29+
if [ -z "${TRUSTSTORE_BUCKET_NAME}" ]; then
30+
echo "could not retrieve truststore_bucket from aws cloudformation list-exports"
31+
exit 1
32+
fi
1333
LATEST_TRUSTSTORE_VERSION=$(aws s3api list-object-versions --bucket "${TRUSTSTORE_BUCKET_NAME}" --prefix "${TRUSTSTORE_FILE}" --query 'Versions[?IsLatest].[VersionId]' --output text)
34+
1435
export LATEST_TRUSTSTORE_VERSION
36+
export ARTIFACT_BUCKET_NAME
37+
export CLOUD_FORMATION_EXECUTION_ROLE
1538

1639
cd ../../ || exit
1740

@@ -27,11 +50,11 @@ sam deploy \
2750
--stack-name "$STACK_NAME" \
2851
--capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
2952
--region eu-west-2 \
30-
--s3-bucket "$artifact_bucket" \
53+
--s3-bucket "$ARTIFACT_BUCKET_NAME" \
3154
--s3-prefix "$ARTIFACT_BUCKET_PREFIX" \
3255
--config-file samconfig_package_and_deploy.toml \
3356
--no-fail-on-empty-changeset \
34-
--role-arn "$cloud_formation_execution_role" \
57+
--role-arn "$CLOUD_FORMATION_EXECUTION_ROLE" \
3558
--no-confirm-changeset \
3659
--force-upload \
3760
--tags "version=$VERSION_NUMBER stack=$STACK_NAME repo=$REPO cfnDriftDetectionGroup=$CFN_DRIFT_DETECTION_GROUP" \

SAMtemplates/alarms/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Resources:
4444
TreatMissingData: notBreaching
4545
ActionsEnabled: !Ref EnableAlerts
4646
AlarmActions:
47-
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
47+
- !ImportValue account-resources-cdk-uk:SNS:SlackAlertsSnsTopicArn:Arn
4848
InsufficientDataActions:
49-
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
49+
- !ImportValue account-resources-cdk-uk:SNS:SlackAlertsSnsTopicArn:Arn
5050
OKActions:
51-
- !ImportValue lambda-resources:SlackAlertsSnsTopicArn
51+
- !ImportValue account-resources-cdk-uk:SNS:SlackAlertsSnsTopicArn:Arn

SAMtemplates/lambda_resources.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ Resources:
8787
Service: "lambda.amazonaws.com"
8888
Action: "sts:AssumeRole"
8989
ManagedPolicyArns:
90-
- !ImportValue lambda-resources:LambdaInsightsLogGroupPolicy
91-
- !ImportValue account-resources:LambdaEncryptCloudwatchKMSPolicy
90+
- !ImportValue account-resources-cdk-uk:IAM:LambdaInsightsLogGroupPolicy:Arn
91+
- !ImportValue account-resources-cdk-uk:IAM:LambdaEncryptCloudwatchKMSPolicy:Arn
9292

9393
LambdaManagedPolicy:
9494
Type: AWS::IAM::ManagedPolicy

SAMtemplates/main_template.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ Resources:
5151
Location: lambda_resources.yaml
5252
Parameters:
5353
StackName: !Ref AWS::StackName
54-
CloudWatchKMSKey: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
55-
SplunkSubscriptionFilterRole: !ImportValue lambda-resources:SplunkSubscriptionFilterRole
56-
SplunkDeliveryStream: !ImportValue lambda-resources:SplunkDeliveryStream
54+
CloudWatchKMSKey: !ImportValue account-resources-cdk-uk:KMS:CloudwatchLogsKmsKey:Arn
55+
SplunkSubscriptionFilterRole: !ImportValue account-resources-cdk-uk:IAM:SplunkSubscriptionFilterRole:Arn
56+
SplunkDeliveryStream: !ImportValue account-resources-cdk-uk:Firehose:SplunkDeliveryStream:Arn
5757
EnableSplunk: "true"
5858
LambdaName: !Sub "${AWS::StackName}-FHIRValidatorUKCore"
5959
LambdaArn: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AWS::StackName}-FHIRValidatorUKCore

0 commit comments

Comments
 (0)