From 0320998b70813321e44ff3324e1be4da0a9aebda Mon Sep 17 00:00:00 2001 From: Michael Lavers Date: Fri, 3 Dec 2021 13:55:11 -0800 Subject: [PATCH] Format SAM Deploy Scripts, Remove Debugging (#98) * Format SAM Deploy Scripts, Remove Debugging * Wrap quotes around s3:// path --- examples/sam/distributedtracing/deploy.sh | 21 +++++++++++---------- examples/sam/dotnet/deploy.sh | 16 +++++++++------- examples/sam/go/deploy.sh | 19 ++++++++++--------- examples/sam/java/deploy.sh | 18 ++++++++++-------- examples/sam/node/deploy.sh | 18 ++++++++++-------- examples/sam/python/deploy.sh | 18 ++++++++++-------- 6 files changed, 60 insertions(+), 50 deletions(-) diff --git a/examples/sam/distributedtracing/deploy.sh b/examples/sam/distributedtracing/deploy.sh index af56751..76f439b 100755 --- a/examples/sam/distributedtracing/deploy.sh +++ b/examples/sam/distributedtracing/deploy.sh @@ -1,21 +1,22 @@ #!/bin/bash accountId=$1 - trustedAccountId=$2 - region=$3 + echo "Deploying example in region ${region} for NR account ${accountId} with trustedAccountId ${trustedAccountId}" -sam build --use-container #--skip-pull-image +sam build --use-container bucket="newrelic-example-${region}-${accountId}" -aws s3 mb --region ${region} s3://${bucket} +aws s3 mb --region "${region}" "s3://${bucket}" + +sam package --region "${region}" --s3-bucket "${bucket}" --output-template-file packaged.yaml -sam package --region ${region} --s3-bucket=${bucket} --output-template-file packaged.yaml -aws cloudformation deploy --region ${region} \ - --template-file packaged.yaml \ - --stack-name Newrelic-Dt-Example \ - --capabilities CAPABILITY_IAM \ - --parameter-overrides "NRAccountId=${accountId}" "TrustedAccountId=${trustedAccountId}" +sam deploy \ + --region "${region}" \ + --template-file packaged.yaml \ + --stack-name Newrelic-Dt-Example \ + --capabilities CAPABILITY_IAM \ + --parameter-overrides "NRAccountId=${accountId}" "TrustedAccountId=${trustedAccountId}" diff --git a/examples/sam/dotnet/deploy.sh b/examples/sam/dotnet/deploy.sh index f7fa50b..bece53a 100755 --- a/examples/sam/dotnet/deploy.sh +++ b/examples/sam/dotnet/deploy.sh @@ -9,11 +9,13 @@ sam build bucket="newrelic-example-${region}-${accountId}" -aws s3 mb --region ${region} s3://${bucket} +aws s3 mb --region "${region}" "s3://${bucket}" -sam package --region ${region} --s3-bucket=${bucket} --output-template-file packaged.yaml -aws cloudformation deploy --region ${region} \ - --template-file packaged.yaml \ - --stack-name NewrelicExampleDotnet \ - --capabilities CAPABILITY_IAM \ - --parameter-overrides "NRAccountId=${accountId}" +sam package --region "${region}" --s3-bucket "${bucket}" --output-template-file packaged.yaml + +sam deploy \ + --region "${region}" \ + --template-file packaged.yaml \ + --stack-name NewrelicExampleDotnet \ + --capabilities CAPABILITY_IAM \ + --parameter-overrides "NRAccountId=${accountId}" diff --git a/examples/sam/go/deploy.sh b/examples/sam/go/deploy.sh index 86aeab8..074b86e 100755 --- a/examples/sam/go/deploy.sh +++ b/examples/sam/go/deploy.sh @@ -7,7 +7,6 @@ echo "region set to ${region}" # The Go1.x runtime does not support Lambda Extensions. Instead, Go Lambdas should be written # against the "provided" runtime. The aws-lambda-go SDK provides a build tag that makes this easy. -runtime="provided" echo "Building stand-alone lambda" build_tags="-tags lambda.norpc" @@ -15,14 +14,16 @@ build_tags="-tags lambda.norpc" # Custom runtimes need a bootstrap executable. See https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html handler="bootstrap" -env GOARCH=amd64 GOOS=linux go build ${build_tags} -ldflags="-s -w" -o ${handler} +env GOARCH=amd64 GOOS=linux go build "${build_tags}" -ldflags="-s -w" -o ${handler} zip go-example.zip "${handler}" bucket="newrelic-example-${region}-${accountId}" -aws s3 mb --region ${region} s3://${bucket} -aws s3 cp go-example.zip s3://${bucket} -aws cloudformation deploy --region ${region} \ - --template-file template.yaml \ - --stack-name NewrelicExampleGo \ - --capabilities CAPABILITY_IAM \ - --parameter-overrides "NRAccountId=${accountId}" +aws s3 mb --region "${region}" "s3://${bucket}" +aws s3 cp go-example.zip s3://"${bucket}" + +aws cloudformation deploy \ + --region "${region}" \ + --template-file template.yaml \ + --stack-name NewrelicExampleGo \ + --capabilities CAPABILITY_IAM \ + --parameter-overrides "NRAccountId=${accountId}" diff --git a/examples/sam/java/deploy.sh b/examples/sam/java/deploy.sh index 1b667dd..e7743fe 100755 --- a/examples/sam/java/deploy.sh +++ b/examples/sam/java/deploy.sh @@ -1,19 +1,21 @@ #!/bin/bash accountId=$1 - region=$2 + echo "region set to ${region}" sam build --use-container bucket="newrelic-example-${region}-${accountId}" -#aws s3 mb --region ${region} s3://${bucket} +aws s3 mb --region "${region}" "s3://${bucket}" + +sam package --region "${region}" --s3-bucket "${bucket}" --output-template-file packaged.yaml -sam package --region ${region} --s3-bucket ${bucket} --output-template-file packaged.yaml -sam deploy --region ${region} \ - --template-file packaged.yaml \ - --stack-name NewrelicExampleJava2 \ - --capabilities CAPABILITY_IAM \ - --parameter-overrides "NRAccountId=${accountId}" +sam deploy \ + --region "${region}" \ + --template-file packaged.yaml \ + --stack-name NewrelicExampleJava \ + --capabilities CAPABILITY_IAM \ + --parameter-overrides "NRAccountId=${accountId}" diff --git a/examples/sam/node/deploy.sh b/examples/sam/node/deploy.sh index e3fb1d8..33e29e4 100755 --- a/examples/sam/node/deploy.sh +++ b/examples/sam/node/deploy.sh @@ -1,19 +1,21 @@ #!/bin/bash accountId=$1 - region=$2 + echo "region set to ${region}" sam build --use-container bucket="newrelic-example-${region}-${accountId}" -aws s3 mb --region ${region} s3://${bucket} +aws s3 mb --region "${region}" "s3://${bucket}" + +sam package --region "${region}" --s3-bucket "${bucket}" --output-template-file packaged.yaml -sam package --region ${region} --s3-bucket=${bucket} --output-template-file packaged.yaml -aws cloudformation deploy --region ${region} \ - --template-file packaged.yaml \ - --stack-name NewrelicExampleNode \ - --capabilities CAPABILITY_IAM \ - --parameter-overrides "NRAccountId=${accountId}" +sam deploy \ + --region "${region}" \ + --template-file packaged.yaml \ + --stack-name NewrelicExampleNode \ + --capabilities CAPABILITY_IAM \ + --parameter-overrides "NRAccountId=${accountId}" diff --git a/examples/sam/python/deploy.sh b/examples/sam/python/deploy.sh index e20be9c..cc18209 100755 --- a/examples/sam/python/deploy.sh +++ b/examples/sam/python/deploy.sh @@ -1,19 +1,21 @@ #!/bin/bash accountId=$1 - region=$2 + echo "region set to ${region}" sam build --use-container bucket="newrelic-example-${region}-${accountId}" -aws s3 mb --region ${region} s3://${bucket} +aws s3 mb --region "${region}" "s3://${bucket}" + +sam package --region "${region}" --s3-bucket "${bucket}" --output-template-file packaged.yaml -sam package --region ${region} --s3-bucket=${bucket} --output-template-file packaged.yaml -aws cloudformation deploy --region ${region} \ - --template-file packaged.yaml \ - --stack-name NewrelicExamplePython \ - --capabilities CAPABILITY_IAM \ - --parameter-overrides "NRAccountId=${accountId}" +sam deploy \ + --region "${region}" \ + --template-file packaged.yaml \ + --stack-name NewrelicExamplePython \ + --capabilities CAPABILITY_IAM \ + --parameter-overrides "NRAccountId=${accountId}"