Skip to content
This repository was archived by the owner on Oct 31, 2018. It is now read-only.

Commit 9b38d28

Browse files
committed
Derive region from CLI configuration
1 parent 3d93e08 commit 9b38d28

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ Resizes images on the fly using Amazon S3, AWS Lambda, and Amazon API Gateway. U
1616

1717
1. Deploy the CloudFormation stack
1818

19-
Run `bin/deploy REGION` to deploy the CloudFormation stack. It will create a temporary Amazon S3 bucket, package and upload the function, and create the Lambda function, Amazon API Gateway RestApi, and an S3 bucket for images via CloudFormation. e.g.:
20-
21-
```console
22-
./bin/deploy us-west-2
23-
```
19+
Run `bin/deploy` to deploy the CloudFormation stack. It will create a temporary Amazon S3 bucket, package and upload the function, and create the Lambda function, Amazon API Gateway RestApi, and an S3 bucket for images via CloudFormation.
2420

2521
The deployment script requires the [AWS CLI][cli] version 1.11.19 or newer to be installed.
2622

@@ -41,4 +37,4 @@ This reference architecture sample is [licensed][license] under Apache 2.0.
4137
[license]: LICENSE
4238
[sharp]: https://github.com/lovell/sharp
4339
[amazon-linux]: https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/
44-
[cli]: https://aws.amazon.com/cli/
40+
[cli]: https://aws.amazon.com/cli/

bin/deploy

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
set -o errexit
44

5-
if [ $# -lt 1 ]; then
6-
echo "Usage: deploy REGION"
7-
exit
8-
fi
9-
105
stack_name=ServerlessImageResize
11-
region="$1"
6+
region="$(aws configure get region)"
127
bucket_name="temp-serverless-resize-$(openssl rand -hex 8)"
138
account_id="$(aws sts get-caller-identity --query Account --output text \
149
| xargs echo -n)"
@@ -18,24 +13,21 @@ set -o xtrace
1813
sed -e "s/REGION/${region}/g" -e "s/ACCOUNT_ID/${account_id}/g" \
1914
api-template.yaml > deploy/api.yaml
2015

21-
aws s3 mb "s3://${bucket_name}" --region="${region}"
16+
aws s3 mb "s3://${bucket_name}"
2217

2318
aws cloudformation package \
2419
--output-template-file=deploy/output.yaml \
2520
--template-file=image-resize.yaml \
2621
--s3-bucket="${bucket_name}" \
27-
--region="${region}"
2822

2923
aws cloudformation deploy \
3024
--template-file=deploy/output.yaml \
3125
--stack-name="${stack_name}" \
32-
--capabilities=CAPABILITY_NAMED_IAM \
33-
--region="${region}"
26+
--capabilities=CAPABILITY_NAMED_IAM
3427

35-
aws s3 rb --force "s3://${bucket_name}" --region="${region}"
28+
aws s3 rb --force "s3://${bucket_name}"
3629

3730
aws cloudformation describe-stacks \
3831
--stack-name "${stack_name}" \
3932
--query Stacks[].Outputs \
40-
--region="${region}" \
4133
--output table

0 commit comments

Comments
 (0)