Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ $ echo -e ".env\ndeploy.env\nevent.json\n.lambda" >> .gitignore

```
AWS_ENVIRONMENT // (default: '')
AWS_ENDPOINT // (default: '')
CONFIG_FILE // (default: '')
EVENT_SOURCE_FILE // (default: '')
EXCLUDE_GLOBS // (default: '')
Expand Down Expand Up @@ -117,6 +118,7 @@ Options:
-x, --contextFile [context.json] Context JSON File
-M, --enableRunMultipleEvents [true] Enable run multiple events
-y, --proxy [] Proxy server
-E, --endpoint [] Use different endpoint (e.g. localstack, "http://127.0.0.1:4574")
```

#### package
Expand Down Expand Up @@ -189,6 +191,12 @@ Options:
-y, --proxy [] Proxy server
```

If you are deploying to a custom endpoint you may also need to pass in an access key/secret. For localstack these can be anything, but cannot be blank:

```
node-lambda deploy --endpoint http://localhost:4574 --accessKey '1234' --secretKey '1234'
```

## Custom Environment Variables

AWS Lambda will let you set environment variables for your function. Use the sample `deploy.env` file in combination with the `--configFile` flag to set values which will be added to the lambda configuration upon deploy. Environment variables will also be set when running locally using the same flag
Expand Down
3 changes: 3 additions & 0 deletions bin/node-lambda
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const packageJson = fs.existsSync(path.join(process.cwd(), 'package.json'))
const packageJsonName = packageJson.name || 'UnnamedFunction'

const AWS_ENVIRONMENT = process.env.AWS_ENVIRONMENT || ''
const AWS_ENDPOINT = process.env.AWS_ENDPOINT || ''
const CONFIG_FILE = process.env.CONFIG_FILE || ''
const EVENT_SOURCE_FILE = process.env.EVENT_SOURCE_FILE || ''
const EXCLUDE_GLOBS = process.env.EXCLUDE_GLOBS || ''
Expand Down Expand Up @@ -62,6 +63,8 @@ program
.description('Deploy your application to Amazon Lambda')
.option('-e, --environment [AWS_ENVIRONMENT]', 'Choose environment {dev, staging, production}',
AWS_ENVIRONMENT)
.option('-E, --endpoint [AWS_ENDPOINT]', 'Choose endpoint (e.g. localstack, "http://127.0.0.1:4574")',
AWS_ENDPOINT)
.option('-a, --accessKey [AWS_ACCESS_KEY_ID]', 'AWS Access Key', AWS_ACCESS_KEY_ID)
.option('-s, --secretKey [AWS_SECRET_ACCESS_KEY]', 'AWS Secret Key', AWS_SECRET_ACCESS_KEY)
.option('-P, --profile [AWS_PROFILE]', 'AWS Profile', AWS_PROFILE)
Expand Down
4 changes: 4 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ they may not work as expected in the Lambda environment.
aws.config.httpOptions.agent = proxy(program.proxy)
}

if (program.endpoint) {
aws.config.endpoint = program.endpoint
}

aws.config.update(awsSecurity)

const lambda = new aws.Lambda({ apiVersion: '2015-03-31' })
Expand Down