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

Commit

Permalink
feat(proxy-service): don't hardcode AWS_REGION
Browse files Browse the repository at this point in the history
Removes the hardcoded AWS_REGION from the Serverless config and adds a guard to the predeploy script to check that AWS_REGION is set.
  • Loading branch information
adieuadieu committed Jan 4, 2018
1 parent fda5cac commit 20d338d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
32 changes: 29 additions & 3 deletions serverless/scripts/predeploy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
if (typeof process.env.AWS_REGION === 'undefined') {
console.error(`
Please set the "AWS_REGION" environment variable to the AWS region to which you wish to deploy.
These are some cheap options:
Ireland: eu-west-1
USA, Virginia: us-east-1
USA, Oregon: us-west-2
For example:
export AWS_REGION=eu-west-1
`)
process.exit(1)
}

if (typeof process.env.AWS_IOT_HOST === 'undefined') {
console.error(`
Please set the "AWS_IOT_HOST" environment variable to your region's AWS IoT Custom Endpoint.
Please set the "AWS_IOT_HOST" environment variable to your ${
process.env.AWS_REGION
} region's AWS IoT Custom Endpoint.
You can find it here:
https://eu-west-1.console.aws.amazon.com/iot/home#/settings
https://eu-west-1.console.aws.amazon.com/iot/home?region=${
process.env.AWS_REGION
}#/settings
Or with the AWS CLI:
aws iot describe-endpoint --output text
aws iot describe-endpoint --output text --region ${process.env.AWS_REGION}
For Example:
export AWS_REGION=replacethispart.iot.eu-west-1.amazonaws.com
`)
process.exit(1)
}
8 changes: 5 additions & 3 deletions serverless/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ service: chromeless-serverless
custom:
stage: dev
debug: "*"
awsIotHost: ${env:AWS_IOT_HOST}
aws:
iotHost: ${env:AWS_IOT_HOST}
region: ${env:AWS_REGION}
chrome:
functions:
- run
Expand All @@ -12,10 +14,10 @@ provider:
name: aws
runtime: nodejs6.10
stage: ${self:custom.stage}
region: eu-west-1
region: ${self:custom.aws.region}
environment:
DEBUG: ${self:custom.debug}
AWS_IOT_HOST: ${self:custom.awsIotHost}
AWS_IOT_HOST: ${self:custom.aws.iotHost}
apiKeys:
- ${self:custom.stage}-chromeless-session-key
iamRoleStatements:
Expand Down

0 comments on commit 20d338d

Please sign in to comment.