
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@aws-cdk/aws-lambda
Advanced tools
This construct library allows you to define AWS Lambda Functions.
import lambda = require('@aws-cdk/aws-lambda');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NodeJS810,
handler: 'index.handler',
code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
});
The lambda.Code
class includes static convenience methods for various types of
runtime code.
lambda.Code.bucket(bucket, key[, objectVersion])
- specify an S3 object that
contains the archive of your runtime code.lambda.Code.inline(code)
- inline the handle code as a string. This is
limited to 4KB. The class InlineJavaScriptLambda
can be used to simplify
inlining JavaScript functions.lambda.Code.directory(directory)
- specify a directory in the local filesystem
which will be zipped and uploaded to S3 before deployment.lambda.Code.file(path)
- specify a file to be used for Lambda code. This can
be, for example a JAR or a ZIP file, based on the runtime used.The following example shows how to define a Python function and deploy the code from the
local directory my-lambda-handler
to it:
Example of Lambda Code from Local Assets
When deploying a stack that contains this code, the directory will be zip archived and then uploaded to an S3 bucket, then the exact location of the S3 objects will be passed when the stack is deployed.
This module also contains an Action that allows you to invoke a Lambda function from CodePipeline:
import codepipeline = require('@aws-cdk/aws-codepipeline');
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const lambdaStage = pipeline.addStage('Lambda');
new lambda.PipelineInvokeAction(this, 'Lambda', {
stage: lambdaStage,
lambda: fn,
});
You can also add the Lambda to the Pipeline directly:
// equivalent to the code above:
fn.addToPipeline(lambdaStage, 'Lambda');
See the AWS documentation on how to write a Lambda function invoked from CodePipeline.
import lambda = require('@aws-cdk/aws-lambda');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NodeJS810,
handler: 'index.handler',
code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
deadLetterQueueEnabled: true
});
See the AWS documentation to learn more about AWS Lambdas and DLQs.
import lambda = require('@aws-cdk/aws-lambda');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NodeJS810,
handler: 'index.handler',
code: lambda.Code.inline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
tracing: lambda.Tracing.Active
});
See the AWS documentation to learn more about AWS Lambda's X-Ray support.
0.12.0 (2018-10-12)
IMPORTANT NOTE: This release includes a fix for a bug that would make the toolkit unusable for multi-stack applications. In order to benefit from this fix, a globally installed CDK toolkit must also be updated:
$ npm i -g aws-cdk
$ cdk --version
0.12.0 (build ...)
Like always, you will also need to update your project's library versions:
Language | Update?
--------------------------- | ------------------------------------------------------------------------------------------------------------------
JavaScript/TypeScript (npm) | npx npm-check-updates -u
Java (maven) | mvn versions:use-latest-versions
.NET (NuGet) | nuget update
aws-codepipeline: this commit contains the following breaking changes:
Previously, we always required customers to explicitly name the output artifacts the Actions used in the Pipeline, and to explicitly "wire together" the outputs of one Action as inputs to another. With this change, the CodePipeline Construct generates artifact names, if the customer didn't provide one explicitly, and tries to find the first available output artifact to use as input to a newly created Action that needs it, thus turning both the input and output artifacts from required to optional properties.
FAQs
The CDK Construct Library for AWS::Lambda
The npm package @aws-cdk/aws-lambda receives a total of 84,537 weekly downloads. As such, @aws-cdk/aws-lambda popularity was classified as popular.
We found that @aws-cdk/aws-lambda demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.