diff --git a/README.md b/README.md index e87217f..2a4e268 100644 --- a/README.md +++ b/README.md @@ -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: '') @@ -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: "") diff --git a/lib/main.js b/lib/main.js index f163bb5..98203a2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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, @@ -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 } diff --git a/test/main.js b/test/main.js index 111372f..8c66755 100644 --- a/test/main.js +++ b/test/main.js @@ -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', () => { @@ -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)