Skip to content

Commit 770be30

Browse files
committed
simplify deploy scripts
1 parent 50d9703 commit 770be30

33 files changed

+41
-70
lines changed

sample-apps/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
node_modules
2+
npm-debug.log
23
package-lock.json
34
package
4-
out.yml
5+
*out.yml
56
out.json
67
bucket-name.txt
78
target
89
build
910
.gradle
1011
*.zip
12+
bin
13+
obj

sample-apps/blank-java/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
33
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
44
echo $BUCKET_NAME > bucket-name.txt
55
aws s3 mb s3://$BUCKET_NAME
6-
cp 2-deploy.sh.template 2-deploy.sh
7-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 2-deploy.sh

sample-apps/blank-java/2-deploy.sh.template renamed to sample-apps/blank-java/2-deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -eo pipefail
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
34
TEMPLATE=template.yml
45
if [ $1 ]
56
then
@@ -11,5 +12,5 @@ then
1112
else
1213
gradle build -i
1314
fi
14-
aws cloudformation package --template-file $TEMPLATE --s3-bucket MY_BUCKET --output-template-file out.yml
15+
aws cloudformation package --template-file $TEMPLATE --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
1516
aws cloudformation deploy --template-file out.yml --stack-name blank-java --capabilities CAPABILITY_NAMED_IAM

sample-apps/blank-java/4-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ if [ -f bucket-name.txt ]; then
1313
esac
1414
done
1515
fi
16-
rm -f 2-deploy.sh out.yml out.json
16+
rm -f out.yml out.json
1717
rm -rf build .gradle target

sample-apps/blank-python/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
33
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
44
echo $BUCKET_NAME > bucket-name.txt
55
aws s3 mb s3://$BUCKET_NAME
6-
cp 2-deploy.sh.template 2-deploy.sh
7-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 2-deploy.sh

sample-apps/blank-python/2-deploy.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
4+
cd function
5+
rm -rf package
6+
pip install --target ./package -r requirements.txt
7+
cp lambda_function.py package
8+
cd ../
9+
aws cloudformation package --template-file template.yml --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
10+
aws cloudformation deploy --template-file out.yml --stack-name blank-python --capabilities CAPABILITY_NAMED_IAM

sample-apps/blank-python/2-deploy.sh.template

Lines changed: 0 additions & 4 deletions
This file was deleted.

sample-apps/blank-python/4-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ if [ -f bucket-name.txt ]; then
1313
esac
1414
done
1515
fi
16-
rm -f 2-deploy.sh out.yml out.json
16+
rm -f out.yml out.json
1717
rm -rf function/package

sample-apps/blank-ruby/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
33
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
44
echo $BUCKET_NAME > bucket-name.txt
55
aws s3 mb s3://$BUCKET_NAME
6-
cp 2-deploy.sh.template 2-deploy.sh
7-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 2-deploy.sh
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
22
set -eo pipefail
3-
aws cloudformation package --template-file template.yml --s3-bucket MY_BUCKET --output-template-file out.yml
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
4+
aws cloudformation package --template-file template.yml --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
45
aws cloudformation deploy --template-file out.yml --stack-name blank-ruby --capabilities CAPABILITY_NAMED_IAM

sample-apps/blank-ruby/4-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ if [ -f bucket-name.txt ]; then
1313
esac
1414
done
1515
fi
16-
rm -f 2-deploy.sh out.yml out.json
16+
rm -f out.yml out.json
1717
rm -rf function/node_modules function/package-lock.json

sample-apps/blank/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
33
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
44
echo $BUCKET_NAME > bucket-name.txt
55
aws s3 mb s3://$BUCKET_NAME
6-
cp 2-deploy.sh.template 2-deploy.sh
7-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 2-deploy.sh
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22
set -eo pipefail
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
34
cd function
45
npm install --production
56
cd ../
6-
aws cloudformation package --template-file template.yml --s3-bucket MY_BUCKET --output-template-file out.yml
7+
aws cloudformation package --template-file template.yml --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
78
aws cloudformation deploy --template-file out.yml --stack-name blank --capabilities CAPABILITY_NAMED_IAM

sample-apps/blank/4-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ if [ -f bucket-name.txt ]; then
1313
esac
1414
done
1515
fi
16-
rm -f 2-deploy.sh out.yml out.json
16+
rm -f out.yml out.json
1717
rm -rf function/node_modules function/package-lock.json

sample-apps/ec2-spot/.gitignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

sample-apps/ec2-spot/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
33
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
44
echo $BUCKET_NAME > bucket-name.txt
55
aws s3 mb s3://$BUCKET_NAME
6-
cp 2-deploy.sh.template 2-deploy.sh
7-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 2-deploy.sh
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22
set -eo pipefail
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
34
cd src/ec2spot
45
dotnet lambda package
56
cd ../../
6-
aws cloudformation package --template-file template.yml --s3-bucket MY_BUCKET --output-template-file out.yml
7+
aws cloudformation package --template-file template.yml --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
78
aws cloudformation deploy --template-file out.yml --stack-name ec2-spot --capabilities CAPABILITY_NAMED_IAM

sample-apps/ec2-spot/4-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ if [ -f bucket-name.txt ]; then
1212
esac
1313
done
1414
fi
15-
rm -f 2-deploy.sh out.yml
15+
rm -f out.yml out.json

sample-apps/error-processor/.gitignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

sample-apps/error-processor/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
33
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
44
echo $BUCKET_NAME > bucket-name.txt
55
aws s3 mb s3://$BUCKET_NAME
6-
cp 2-deploy.sh.template 2-deploy.sh
7-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 2-deploy.sh
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash
22
cd processor
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
34
npm install --production
45
cd ../random-error
56
npm install --production
67
cd ../
7-
aws cloudformation package --template-file template.yml --s3-bucket MY_BUCKET --output-template-file out.yml
8+
aws cloudformation package --template-file template.yml --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
89
aws cloudformation deploy --template-file out.yml --stack-name error-processor --capabilities CAPABILITY_NAMED_IAM

sample-apps/error-processor/4-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ if [ -f bucket-name.txt ]; then
1919
esac
2020
done
2121
fi
22-
rm -f 2-deploy.sh out.yml out.json
22+
rm -f out.yml out.json
2323
rm -rf processor/node_modules random-error/node_modules processor/package-lock.json random-error/package-lock.json

sample-apps/java-basic/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
33
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
44
echo $BUCKET_NAME > bucket-name.txt
55
aws s3 mb s3://$BUCKET_NAME
6-
cp 2-deploy.sh.template 2-deploy.sh
7-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 2-deploy.sh

sample-apps/java-basic/2-deploy.sh.template renamed to sample-apps/java-basic/2-deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -eo pipefail
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
34
TEMPLATE=template.yml
45
if [ $1 ]
56
then
@@ -11,5 +12,5 @@ then
1112
else
1213
gradle build -i
1314
fi
14-
aws cloudformation package --template-file $TEMPLATE --s3-bucket MY_BUCKET --output-template-file out.yml
15+
aws cloudformation package --template-file $TEMPLATE --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
1516
aws cloudformation deploy --template-file out.yml --stack-name java-basic --capabilities CAPABILITY_NAMED_IAM

sample-apps/java-basic/4-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ if [ -f bucket-name.txt ]; then
1313
esac
1414
done
1515
fi
16-
rm -f 2-deploy.sh out.yml out.json
16+
rm -f out.yml out.json
1717
rm -rf build .gradle target

sample-apps/list-manager/.gitignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

sample-apps/list-manager/1-create-bucket.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \
44
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
55
echo $BUCKET_NAME > bucket-name.txt
66
aws s3 mb s3://$BUCKET_NAME
7-
cp 4-deploy.sh.template 4-deploy.sh
8-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 4-deploy.sh
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22
set -eo pipefail
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
34
cd lib/nodejs && npm install && cd ../../
4-
aws cloudformation package --template-file template.yml --s3-bucket MY_BUCKET --output-template-file out.yml
5+
aws cloudformation package --template-file template.yml --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
56
aws cloudformation deploy --template-file out.yml --stack-name list-manager --capabilities CAPABILITY_NAMED_IAM

sample-apps/list-manager/8-cleanup.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ if [ -f bucket-name.txt ]; then
1414
esac
1515
done
1616
fi
17-
18-
rm out.yml out.json 4-deploy.sh
17+
rm out.yml out.json
1918
rm -rf lib/nodejs/node_modules

sample-apps/rds-mysql/.gitignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

sample-apps/rds-mysql/1-create-bucket.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ set -eo pipefail
33
BUCKET_ID=$(dd if=/dev/random bs=8 count=1 2>/dev/null | od -An -tx1 | tr -d ' \t\n')
44
BUCKET_NAME=lambda-artifacts-$BUCKET_ID
55
echo $BUCKET_NAME > bucket-name.txt
6-
aws s3 mb s3://$BUCKET_NAME
7-
cp 4-deploy.sh.template 4-deploy.sh
8-
sed -i'' -e "s/MY_BUCKET/$BUCKET_NAME/" 4-deploy.sh
6+
aws s3 mb s3://$BUCKET_NAME

sample-apps/rds-mysql/4-deploy.sh.template renamed to sample-apps/rds-mysql/4-deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
22
set -eo pipefail
3+
ARTIFACT_BUCKET=$(cat bucket-name.txt)
34
STACK=rds-mysql
45
if [[ $# -eq 1 ]] ; then
56
STACK=$1
67
echo "Deploying to stack $STACK"
78
fi
89
cd lib/nodejs && npm install && cd ../../
9-
aws cloudformation package --template-file template.yml --s3-bucket MY_BUCKET --output-template-file out.yml
10+
aws cloudformation package --template-file template.yml --s3-bucket $ARTIFACT_BUCKET --output-template-file out.yml
1011
aws cloudformation deploy --template-file out.yml --stack-name $STACK --capabilities CAPABILITY_NAMED_IAM
1112

1213
# attach to different VPC

sample-apps/rds-mysql/7-cleanup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ if [ -f bucket-name.txt ]; then
1818
esac
1919
done
2020
fi
21+
22+
rm out.yml out.json

0 commit comments

Comments
 (0)