Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
eventHandler(streamEvent, functionName, shardId, chunk, cb) {
const streamName = streamEvent.arn.split('/')[1];
this.serverless.cli.log(`${streamName} (λ: ${functionName})`);
const {location = '.'} = this.service.custom['serverless-offline'];
const __function = this.service.getFunction(functionName);
const servicePath = join(this.serverless.config.servicePath, location);
const funOptions = getFunctionOptions(__function, functionName, servicePath);
const handler = createHandler(funOptions, {});
const lambdaContext = createLambdaContext(__function, (err, data) => {
this.serverless.cli.log(
`[${err ? figures.cross : figures.tick}] ${JSON.stringify(data) || ''}`
);
cb(err, data);
});
const event = {
Records: chunk.map(({SequenceNumber, ApproximateArrivalTimestamp, Data, PartitionKey}) => ({
kinesis: {
partitionKey: PartitionKey,
kinesisSchemaVersion: '1.0',
data: Data.toString('base64'),
sequenceNumber: SequenceNumber
eventHandler(queueEvent, functionName, messages, cb) {
if (!messages) return cb();
const streamName = this.getQueueName(queueEvent);
this.serverless.cli.log(`${streamName} (λ: ${functionName})`);
const {location = '.'} = getConfig(this.service, 'serverless-offline');
const __function = this.service.getFunction(functionName);
const servicePath = join(this.serverless.config.servicePath, location);
const funOptions = getFunctionOptions(__function, functionName, servicePath);
const handler = createHandler(funOptions, {});
const lambdaContext = createLambdaContext(__function, (err, data) => {
this.serverless.cli.log(
`[${err ? figures.cross : figures.tick}] ${JSON.stringify(data) || ''}`
);
cb(err, data);
});
const event = {
Records: messages.map(
({
MessageId: messageId,
ReceiptHandle: receiptHandle,
Body: body,
Attributes: attributes,
Object.keys(this.service.functions).forEach(key => {
const fun = this._getFunction(key)
const funName = key
const servicePath = path.join(this.serverless.config.servicePath, location)
const funOptions = functionHelper.getFunctionOptions(fun, key, servicePath)
this.debug(`funOptions ${JSON.stringify(funOptions, null, 2)} `)
if (!fun.environment) {
fun.environment = {}
}
fun.environment.AWS_LAMBDA_FUNCTION_NAME = `${this.service.service}-${this.service.provider.stage}-${funName}`
this.debug('')
this.debug(funName, 'runtime', runtime, funOptions.babelOptions || '')
this.debug(`events for ${funName}:`)
if (!(fun.events && fun.events.length)) {
this.debug('(none)')
return
}
Object.keys(slsService.functions).forEach(key => {
const fun = getFunction(key, slsService)
const servicePath = path.join(serverless.config.servicePath, location)
const funOptions = functionHelper.getFunctionOptions(fun, key, servicePath)
if (!fun.environment) {
fun.environment = {}
}
if (!(fun.events && fun.events.length)) {
return
}
fun.events.forEach(event => {
if (!event.iot) return
const {iot} = event
const {sql, actions} = iot
const parsed = parseSelect(sql)
ruleConf.Actions.forEach((action) => {
if (action.Lambda) {
const awsFunName = action.Lambda.FunctionArn['Fn::GetAtt'][0]
funName = _.lowerFirst(awsFunName).replace('LambdaFunction', '')
fun = getFunction(funName, slsService)
const servicePath = path.join(serverless.config.servicePath, location)
funOptions = functionHelper.getFunctionOptions(fun, key, servicePath)
if (!fun.environment) {
fun.environment = {}
}
} else {
actions.push(action)
}
})
const {location = '.'} = this.getConfig();
const __function = this.service.getFunction(functionName);
const {env} = process;
const functionEnv = assignAll([
{AWS_REGION: get('service.provider.region', this)},
env,
get('service.provider.environment', this),
get('environment', __function)
]);
process.env = functionEnv;
const serviceRuntime = this.service.provider.runtime;
const servicePath = join(this.serverless.config.servicePath, location);
const funOptions = functionHelper.getFunctionOptions(
__function,
functionName,
servicePath,
serviceRuntime
);
const handler = functionHelper.createHandler(funOptions, this.getConfig());
const lambdaContext = new LambdaContext(__function, this.service.provider, (err, data) => {
this.serverless.cli.log(
`[${err ? figures.cross : figures.tick}] ${functionName} ${JSON.stringify(data) || ''}`
);
cb(err, data);
});
const event = {
Records: chunk.map(({SequenceNumber, ApproximateArrivalTimestamp, Data, PartitionKey}) => ({
kinesis: {
const __function = this.service.getFunction(functionName);
const {env} = process;
const functionEnv = assignAll([
{AWS_REGION: get('service.provider.region', this)},
env,
get('service.provider.environment', this),
get('environment', __function)
]);
process.env = functionEnv;
const serviceRuntime = this.service.provider.runtime;
const servicePath = join(this.serverless.config.servicePath, location);
const funOptions = functionHelper.getFunctionOptions(
__function,
functionName,
servicePath,
serviceRuntime
);
const handler = functionHelper.createHandler(funOptions, config);
const lambdaContext = new LambdaContext(__function, this.service.provider, (err, data) => {
this.serverless.cli.log(
`[${err ? figures.cross : figures.tick}] ${functionName} ${JSON.stringify(data) || ''}`
);
cb(err, data);
});
const awsRegion = config.region || 'us-west-2';
const awsAccountId = config.accountId || '000000000000';