Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supported TracingConfig #243

Merged
merged 2 commits into from
Apr 25, 2017
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ $ node-lambda deploy --help
-b, --vpcSubnets [] VPC Subnet ID(s, comma separated list) for your Lambda Function, when using this, the below param is also required
-g, --vpcSecurityGroups [] VPC Security Group ID(s, comma separated list) for your Lambda Function, when using this, the above param is also required
-Q, --deadLetterConfigTargetArn [] Lambda DLQ resource
-T, --tracingConfig [] Lambda tracing settings
-A, --packageDirectory [] Local package directory
-S, --eventSourceFile [event_sources.json] Path to file holding event source mapping variables (e.g. "event_sources.json")
-x, --excludeGlobs [] Add a space separated list of file(type)s to ignore (e.g. "*.json .env")
Expand Down
3 changes: 3 additions & 0 deletions bin/node-lambda
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var AWS_PUBLISH = process.env.AWS_PUBLISH || false;
var AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION || '';
var AWS_VPC_SUBNETS = process.env.AWS_VPC_SUBNETS || '';
var AWS_VPC_SECURITY_GROUPS = process.env.AWS_VPC_SECURITY_GROUPS || '';
var AWS_TRACING_CONFIG = process.env.AWS_TRACING_CONFIG || '';
var EVENT_FILE = process.env.EVENT_FILE || 'event.json';
var PACKAGE_DIRECTORY = process.env.PACKAGE_DIRECTORY;
var CONTEXT_FILE = process.env.CONTEXT_FILE || 'context.json';
Expand Down Expand Up @@ -69,6 +70,8 @@ program
AWS_VPC_SECURITY_GROUPS)
.option('-Q, --deadLetterConfigTargetArn [' + AWS_DLQ_TARGET_ARN + ']', 'Lambda DLQ resource',
AWS_DLQ_TARGET_ARN)
.option('-T, --tracingConfig [' + AWS_TRACING_CONFIG + ']', 'Lambda tracing settings',
AWS_TRACING_CONFIG)
.option('-A, --packageDirectory [' + PACKAGE_DIRECTORY + ']', 'Local Package Directory', PACKAGE_DIRECTORY)
.option('-f, --configFile [' + CONFIG_FILE + ']',
'Path to file holding secret environment variables (e.g. "deploy.env")', CONFIG_FILE)
Expand Down
1 change: 1 addition & 0 deletions lib/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ AWS_DESCRIPTION=
AWS_RUNTIME=nodejs6.10
AWS_VPC_SUBNETS=
AWS_VPC_SECURITY_GROUPS=
AWS_TRACING_CONFIG=
EXCLUDE_GLOBS="event.json"
PACKAGE_DIRECTORY=build
9 changes: 8 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ Lambda.prototype._params = function (program, buffer) {
},
DeadLetterConfig: {
TargetArn: null
},
TracingConfig: {
Mode: null
}
};
if (program.lambdaVersion) {
Expand All @@ -133,6 +136,9 @@ Lambda.prototype._params = function (program, buffer) {
TargetArn: program.deadLetterConfigTargetArn
};
}
if (program.tracingConfig) {
params.TracingConfig.Mode = program.tracingConfig;
}

return params;
};
Expand Down Expand Up @@ -390,7 +396,8 @@ Lambda.prototype._uploadExisting = function (lambda, params, cb) {
'Runtime': params.Runtime,
'VpcConfig': params.VpcConfig,
'Environment': params.Environment,
'DeadLetterConfig': params.DeadLetterConfig
'DeadLetterConfig': params.DeadLetterConfig,
'TracingConfig': params.TracingConfig,
}, function (err, data) {
return cb(err, data);
});
Expand Down
13 changes: 13 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var originalProgram = {
description: '',
runtime: 'nodejs6.10',
deadLetterConfigTargetArn: '',
tracingConfig: '',
region: 'us-east-1,us-west-2,eu-west-1',
eventFile: 'event.json',
eventSourceFile: '',
Expand Down Expand Up @@ -97,6 +98,18 @@ describe('node-lambda', function () {
assert.isNull(params.DeadLetterConfig.TargetArn);
});

it('appends TracingConfig to params when params set', function() {
program.tracingConfig = 'Active';
const params = lambda._params(program);
assert.equal(params.TracingConfig.Mode, 'Active');
});

it('does not append TracingConfig when params are not set', function() {
program.tracingConfig = '';
const params = lambda._params(program);
assert.isNull(params.TracingConfig.Mode);
});

describe('configFile', function () {
beforeEach(function () {
// Prep...
Expand Down