From ed3b766cc7e3aac419e206c918643b9d038e82f5 Mon Sep 17 00:00:00 2001 From: TophrC-dd Date: Thu, 27 Mar 2025 14:37:41 -0400 Subject: [PATCH 1/5] Fixing the release script to modify the template when deploying to sandbox --- serverless/release.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/serverless/release.sh b/serverless/release.sh index aca13348..a6af2a8b 100755 --- a/serverless/release.sh +++ b/serverless/release.sh @@ -109,12 +109,19 @@ if [ "$PROD_RELEASE" = true ] ; then MACRO_SOURCE_URL="https://github.com/DataDog/datadog-cloudformation-macro/releases/download/serverless-macro-${VERSION}/serverless-macro-${VERSION}.zip'" else VERSION=$CI_COMMIT_SHA - echo "About to release non-public staging version of macro, upload serverless-macro-${VERSION} to s3, and upload the template.yml to s3://${BUCKET}/aws/serverless-macro-staging/${VERSION}.yml" + CURRENT_VERSION=$(grep -o 'Version: [0-9]\+\.[0-9]\+\.[0-9]\+' template.yml | cut -d' ' -f2) + MACRO_SOURCE_URL="s3://${BUCKET}/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip" + TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/serverless-macro-staging/latest.yml" + #Replace the current version with the SHA hash of the commit + echo "Setting current version to ${VERSION}" + perl -pi -e "s/Version: ${CURRENT_VERSION}/Version: ${VERSION}/g" template.yml + # Replace the default SourceZipUrl to the staging path + echo "Replacing the default SourceZipUrl to the staging path" + perl -pi -e "s/github.com\/DataDog\/datadog-cloudformation-macro\/releases\/download\/serverless-macro-\$\{VERSION\}\//${BUCKET}.s3.amazonaws.com\/aws\/serverless-macro-staging-zip\//g" template.yml # Upload to s3 instead of github + echo "About to release non-public staging version of macro, upload serverless-macro-${VERSION} to s3, and upload the template.yml to s3://${BUCKET}/aws/serverless-macro-staging/${VERSION}.yml" tools/build_zip.sh "${VERSION}" - aws s3 cp .macro/serverless-macro-${VERSION}.zip s3://${BUCKET}/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip - TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/serverless-macro-staging/latest.yml" - MACRO_SOURCE_URL="s3://${BUCKET}/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip" + aws s3 cp .macro/serverless-macro-${VERSION}.zip ${MACRO_SOURCE_URL} fi # Upload the template to the S3 bucket From b3054282e8b34d1966694b6bba1d21abbf42c941 Mon Sep 17 00:00:00 2001 From: TophrC-dd Date: Thu, 27 Mar 2025 14:43:26 -0400 Subject: [PATCH 2/5] remove redundant variable --- serverless/release.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/serverless/release.sh b/serverless/release.sh index a6af2a8b..b034b56c 100755 --- a/serverless/release.sh +++ b/serverless/release.sh @@ -109,7 +109,6 @@ if [ "$PROD_RELEASE" = true ] ; then MACRO_SOURCE_URL="https://github.com/DataDog/datadog-cloudformation-macro/releases/download/serverless-macro-${VERSION}/serverless-macro-${VERSION}.zip'" else VERSION=$CI_COMMIT_SHA - CURRENT_VERSION=$(grep -o 'Version: [0-9]\+\.[0-9]\+\.[0-9]\+' template.yml | cut -d' ' -f2) MACRO_SOURCE_URL="s3://${BUCKET}/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip" TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/serverless-macro-staging/latest.yml" #Replace the current version with the SHA hash of the commit From e9d1272f6024d38c4525dd5414cb65a55e4c92a9 Mon Sep 17 00:00:00 2001 From: TophrC-dd Date: Thu, 27 Mar 2025 14:47:58 -0400 Subject: [PATCH 3/5] enhance readability --- serverless/release.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serverless/release.sh b/serverless/release.sh index b034b56c..33cc6263 100755 --- a/serverless/release.sh +++ b/serverless/release.sh @@ -111,12 +111,15 @@ else VERSION=$CI_COMMIT_SHA MACRO_SOURCE_URL="s3://${BUCKET}/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip" TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/serverless-macro-staging/latest.yml" + #Replace the current version with the SHA hash of the commit echo "Setting current version to ${VERSION}" perl -pi -e "s/Version: ${CURRENT_VERSION}/Version: ${VERSION}/g" template.yml + # Replace the default SourceZipUrl to the staging path echo "Replacing the default SourceZipUrl to the staging path" perl -pi -e "s/github.com\/DataDog\/datadog-cloudformation-macro\/releases\/download\/serverless-macro-\$\{VERSION\}\//${BUCKET}.s3.amazonaws.com\/aws\/serverless-macro-staging-zip\//g" template.yml + # Upload to s3 instead of github echo "About to release non-public staging version of macro, upload serverless-macro-${VERSION} to s3, and upload the template.yml to s3://${BUCKET}/aws/serverless-macro-staging/${VERSION}.yml" tools/build_zip.sh "${VERSION}" From cabcf6e3ca240e4ddc0b9c38b7f5b4b23e4ebd0c Mon Sep 17 00:00:00 2001 From: TophrC-dd Date: Thu, 27 Mar 2025 14:58:11 -0400 Subject: [PATCH 4/5] fixing escaped characters --- serverless/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serverless/release.sh b/serverless/release.sh index 33cc6263..1e9209bf 100755 --- a/serverless/release.sh +++ b/serverless/release.sh @@ -118,7 +118,7 @@ else # Replace the default SourceZipUrl to the staging path echo "Replacing the default SourceZipUrl to the staging path" - perl -pi -e "s/github.com\/DataDog\/datadog-cloudformation-macro\/releases\/download\/serverless-macro-\$\{VERSION\}\//${BUCKET}.s3.amazonaws.com\/aws\/serverless-macro-staging-zip\//g" template.yml + perl -pi -e "s/github.com\/DataDog\/datadog-cloudformation-macro\/releases\/download\/serverless-macro-\${VERSION}/${BUCKET}.s3.amazonaws.com\/aws\/serverless-macro-staging-zip\//g" template.yml # Upload to s3 instead of github echo "About to release non-public staging version of macro, upload serverless-macro-${VERSION} to s3, and upload the template.yml to s3://${BUCKET}/aws/serverless-macro-staging/${VERSION}.yml" From 89a15d46bbc71ea2de7f1a6aaba70fa641ac0952 Mon Sep 17 00:00:00 2001 From: TophrC-dd Date: Thu, 3 Apr 2025 10:40:53 -0400 Subject: [PATCH 5/5] just passing values through the url params is a less complicated approach --- serverless/release.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/serverless/release.sh b/serverless/release.sh index 1e9209bf..b3bdcdec 100755 --- a/serverless/release.sh +++ b/serverless/release.sh @@ -109,21 +109,13 @@ if [ "$PROD_RELEASE" = true ] ; then MACRO_SOURCE_URL="https://github.com/DataDog/datadog-cloudformation-macro/releases/download/serverless-macro-${VERSION}/serverless-macro-${VERSION}.zip'" else VERSION=$CI_COMMIT_SHA - MACRO_SOURCE_URL="s3://${BUCKET}/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip" + MACRO_SOURCE_URL="https://${BUCKET}.s3.amazonaws.com/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip" TEMPLATE_URL="https://${BUCKET}.s3.amazonaws.com/aws/serverless-macro-staging/latest.yml" - - #Replace the current version with the SHA hash of the commit - echo "Setting current version to ${VERSION}" - perl -pi -e "s/Version: ${CURRENT_VERSION}/Version: ${VERSION}/g" template.yml - - # Replace the default SourceZipUrl to the staging path - echo "Replacing the default SourceZipUrl to the staging path" - perl -pi -e "s/github.com\/DataDog\/datadog-cloudformation-macro\/releases\/download\/serverless-macro-\${VERSION}/${BUCKET}.s3.amazonaws.com\/aws\/serverless-macro-staging-zip\//g" template.yml - + # Upload to s3 instead of github echo "About to release non-public staging version of macro, upload serverless-macro-${VERSION} to s3, and upload the template.yml to s3://${BUCKET}/aws/serverless-macro-staging/${VERSION}.yml" tools/build_zip.sh "${VERSION}" - aws s3 cp .macro/serverless-macro-${VERSION}.zip ${MACRO_SOURCE_URL} + aws s3 cp .macro/serverless-macro-${VERSION}.zip s3://${BUCKET}/aws/serverless-macro-staging-zip/serverless-macro-${VERSION}.zip fi # Upload the template to the S3 bucket @@ -143,7 +135,7 @@ else fi echo "Done uploading the template, and here is the CloudFormation quick launch URL" -echo "https://console.aws.amazon.com/cloudformation/home#/stacks/quickCreate?stackName=datadog-serverless-macro&templateURL=${TEMPLATE_URL}" +echo "https://console.aws.amazon.com/cloudformation/home#/stacks/quickCreate?stackName=datadog-serverless-macro&templateURL=${TEMPLATE_URL}¶m_SourceZipUrl=${MACRO_SOURCE_URL}" echo "Done!"