Skip to content

Commit 4245e42

Browse files
committed
check vars
1 parent 8af2eba commit 4245e42

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

.github/scripts/release_code.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,43 @@ export AWS_MAX_ATTEMPTS
66
echo "$COMMIT_ID"
77

88
CF_LONDON_EXPORTS=$(aws cloudformation list-exports --region eu-west-2 --output json)
9-
artifact_bucket=$(echo "$CF_LONDON_EXPORTS" | \
10-
jq \
11-
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn" \
12-
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
13-
export artifact_bucket
149

15-
cloud_formation_execution_role=$(echo "$CF_LONDON_EXPORTS" | \
10+
ARTIFACT_BUCKET_ARN=$(echo "$CF_LONDON_EXPORTS" | \
11+
jq \
12+
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:ArtifactsBucket:Arn" \
13+
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
14+
ARTIFACT_BUCKET_NAME=$(echo "${ARTIFACT_BUCKET_ARN}" | cut -d ":" -f 6)
15+
16+
if [ -z "${ARTIFACT_BUCKET_NAME}" ]; then
17+
echo "could not retrieve ARTIFACT_BUCKET_NAME from aws cloudformation list-exports"
18+
exit 1
19+
fi
20+
21+
CLOUD_FORMATION_EXECUTION_ROLE=$(echo "$CF_LONDON_EXPORTS" | \
1622
jq \
1723
--arg EXPORT_NAME "iam-cdk:IAM:CloudFormationExecutionRole:Arn" \
1824
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
1925

20-
if [ -z "${cloud_formation_execution_role}" ]; then
21-
echo "could not retrieve ROLE from aws cloudformation list-exports"
26+
if [ -z "${CLOUD_FORMATION_EXECUTION_ROLE}" ]; then
27+
echo "could not retrieve CLOUD_FORMATION_EXECUTION_ROLE from aws cloudformation list-exports"
2228
exit 1
2329
fi
24-
export cloud_formation_execution_role
30+
2531
TRUSTSTORE_BUCKET_ARN=$(echo "$CF_LONDON_EXPORTS" | \
2632
jq \
2733
--arg EXPORT_NAME "account-resources-cdk-uk:Bucket:TrustStoreBucket:Arn" \
2834
-r '.Exports[] | select(.Name == $EXPORT_NAME) | .Value')
2935
TRUSTSTORE_BUCKET_NAME=$(echo "${TRUSTSTORE_BUCKET_ARN}" | cut -d ":" -f 6)
36+
37+
if [ -z "${TRUSTSTORE_BUCKET_NAME}" ]; then
38+
echo "could not retrieve TRUSTSTORE_BUCKET_NAME from aws cloudformation list-exports"
39+
exit 1
40+
fi
41+
3042
LATEST_TRUSTSTORE_VERSION=$(aws s3api list-object-versions --bucket "${TRUSTSTORE_BUCKET_NAME}" --prefix "${TRUSTSTORE_FILE}" --query 'Versions[?IsLatest].[VersionId]' --output text)
43+
44+
export ARTIFACT_BUCKET_NAME
45+
export CLOUD_FORMATION_EXECUTION_ROLE
3146
export LATEST_TRUSTSTORE_VERSION
3247

3348
cd ../../.aws-sam/build || exit
@@ -43,11 +58,11 @@ sam deploy \
4358
--stack-name "$STACK_NAME" \
4459
--capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
4560
--region eu-west-2 \
46-
--s3-bucket "$artifact_bucket" \
61+
--s3-bucket "$ARTIFACT_BUCKET_NAME" \
4762
--s3-prefix "$ARTIFACT_BUCKET_PREFIX" \
4863
--config-file samconfig_package_and_deploy.toml \
4964
--no-fail-on-empty-changeset \
50-
--role-arn "$cloud_formation_execution_role" \
65+
--role-arn "$CLOUD_FORMATION_EXECUTION_ROLE" \
5166
--no-confirm-changeset \
5267
--force-upload \
5368
--tags "version=$VERSION_NUMBER stack=$STACK_NAME repo=$REPO cfnDriftDetectionGroup=$CFN_DRIFT_DETECTION_GROUP" \

0 commit comments

Comments
 (0)