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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ AWS_ARCHITECTURE // (default: 'x86_64')
AWS_DESCRIPTION // (default: package.json.description or '')
AWS_RUNTIME // (default: 'nodejs16.x')
AWS_PUBLISH // (default: false)
AWS_FUNCTION_VERSION // (default: '')
AWS_FUNCTION_VERSION // (default: '') When set, Publish is automatically enabled to create a version and alias.
AWS_VPC_SUBNETS // (default: '')
AWS_VPC_SECURITY_GROUPS // (default: '')
AWS_TRACING_CONFIG // (default: '')
Expand Down Expand Up @@ -193,7 +193,7 @@ Options:
-d, --description [AWS_DESCRIPTION] Lambda Description (default: "Command line tool for locally running and remotely deploying your node.js applications to Amazon Lambda.")
-u, --runtime [AWS_RUNTIME] Lambda Runtime (default: "nodejs16.x")
-p, --publish [AWS_PUBLISH] Lambda Publish (default: false)
-L, --lambdaVersion [AWS_FUNCTION_VERSION] Lambda Function Version (default: "")
-L, --lambdaVersion [AWS_FUNCTION_VERSION] Lambda Function Version. Creates a version and alias. Automatically enables Publish. (default: "")
-b, --vpcSubnets [AWS_VPC_SUBNETS] Lambda Function VPC Subnet IDs (comma delimited) (default: "")
-g, --vpcSecurityGroups [AWS_VPC_SECURITY_GROUPS] Lambda VPC Security Group IDs (comma delimited) (default: "")
-K, --kmsKeyArn [AWS_KMS_KEY_ARN] Lambda KMS Key ARN (default: "")
Expand Down
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ Emulate only the body of the API Gateway event.
_params (program, buffer) {
const params = {
FunctionName: program.functionName +
(program.environment ? '-' + program.environment : '') +
(program.lambdaVersion ? '-' + program.lambdaVersion : ''),
(program.environment ? '-' + program.environment : ''),
Code: {},
Handler: program.handler,
Role: program.role,
Expand All @@ -240,6 +239,7 @@ Emulate only the body of the API Gateway event.
Timeout: program.timeout,
Architectures: program.architecture ? [program.architecture] : ['x86_64'],
Publish: (() => {
if (program.lambdaVersion) return true
if (typeof program.publish === 'boolean') {
return program.publish
}
Expand Down
17 changes: 8 additions & 9 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,18 +279,18 @@ describe('lib/main', function () {
assert.match(params.FunctionName, functionNamePattern)
})

it('appends version to original functionName', () => {
it('does not append version to functionName', () => {
program.lambdaVersion = '2015-02-01'
const params = lambda._params(program)
assert.equal(params.FunctionName, '___node-lambda-development-2015-02-01')
assert.equal(params.FunctionName, '___node-lambda-development')
assert.match(params.FunctionName, functionNamePattern)
})

it('appends version to original functionName (value not allowed by AWS)', () => {
program.lambdaVersion = '2015.02.01'
it('sets Publish to true when lambdaVersion is set', () => {
program.lambdaVersion = 'v1'
program.publish = false
const params = lambda._params(program)
assert.equal(params.FunctionName, '___node-lambda-development-2015_02_01')
assert.match(params.FunctionName, functionNamePattern)
assert.isTrue(params.Publish)
})

it('appends VpcConfig to params when vpc params set', () => {
Expand Down Expand Up @@ -1682,11 +1682,10 @@ describe('lib/main', function () {
})
})

it('creates alias when publish and lambdaVersion are set', () => {
program.publish = true
it('creates alias when lambdaVersion is set', () => {
program.lambdaVersion = 'v1'
const params = lambda._params(program, null)
params.Publish = true
assert.isTrue(params.Publish)
return lambda._deployToRegion(program, params, 'us-east-1').then((result) => {
assert.equal(result.length, 4)
assert.deepEqual(result[3], lambdaMockSettings.updateAlias)
Expand Down
Loading