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

Commit 20d338d

Browse files
committed
feat(proxy-service): don't hardcode AWS_REGION
Removes the hardcoded AWS_REGION from the Serverless config and adds a guard to the predeploy script to check that AWS_REGION is set.
1 parent fda5cac commit 20d338d

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

serverless/scripts/predeploy.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1+
if (typeof process.env.AWS_REGION === 'undefined') {
2+
console.error(`
3+
Please set the "AWS_REGION" environment variable to the AWS region to which you wish to deploy.
4+
5+
These are some cheap options:
6+
7+
Ireland: eu-west-1
8+
USA, Virginia: us-east-1
9+
USA, Oregon: us-west-2
10+
11+
For example:
12+
13+
export AWS_REGION=eu-west-1
14+
`)
15+
process.exit(1)
16+
}
17+
118
if (typeof process.env.AWS_IOT_HOST === 'undefined') {
219
console.error(`
3-
Please set the "AWS_IOT_HOST" environment variable to your region's AWS IoT Custom Endpoint.
20+
Please set the "AWS_IOT_HOST" environment variable to your ${
21+
process.env.AWS_REGION
22+
} region's AWS IoT Custom Endpoint.
423
524
You can find it here:
6-
https://eu-west-1.console.aws.amazon.com/iot/home#/settings
25+
https://eu-west-1.console.aws.amazon.com/iot/home?region=${
26+
process.env.AWS_REGION
27+
}#/settings
728
Or with the AWS CLI:
8-
aws iot describe-endpoint --output text
29+
aws iot describe-endpoint --output text --region ${process.env.AWS_REGION}
30+
31+
For Example:
32+
33+
export AWS_REGION=replacethispart.iot.eu-west-1.amazonaws.com
34+
935
`)
1036
process.exit(1)
1137
}

serverless/serverless.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ service: chromeless-serverless
33
custom:
44
stage: dev
55
debug: "*"
6-
awsIotHost: ${env:AWS_IOT_HOST}
6+
aws:
7+
iotHost: ${env:AWS_IOT_HOST}
8+
region: ${env:AWS_REGION}
79
chrome:
810
functions:
911
- run
@@ -12,10 +14,10 @@ provider:
1214
name: aws
1315
runtime: nodejs6.10
1416
stage: ${self:custom.stage}
15-
region: eu-west-1
17+
region: ${self:custom.aws.region}
1618
environment:
1719
DEBUG: ${self:custom.debug}
18-
AWS_IOT_HOST: ${self:custom.awsIotHost}
20+
AWS_IOT_HOST: ${self:custom.aws.iotHost}
1921
apiKeys:
2022
- ${self:custom.stage}-chromeless-session-key
2123
iamRoleStatements:

0 commit comments

Comments
 (0)