AWS Lambda functions are great. Using the AWS Cloud Development Kit in TypeScript, you can easily deploy files to AWS Lambda functions and configure an AWS Lambda Layer in the same CloudFormation Stack. After the deployment is done, the AWS Lambda function name to invoke the uploaded sources will be exposed as a CloudFormation Stack Output.
import path from "path";
import * as CDK from "@aws-cdk/core";
import * as Lambda from "@aws-cdk/aws-lambda";
const filesLambda = path.resolve(__dirname, "lambda");
const filesLayer = path.resolve(__dirname, "layer");
export class LambdaStack extends CDK.Stack {
constructor(app: CDK.App, id: string, props?: CDK.StackProps) {
super(app, id, props);
const layer = new LayerVersion(this, "Layer", {
compatibleRuntimes: [Runtime.NODEJS_12_X],
code: Code.fromAsset(filesLayer),
});
const lambda = new Lambda.Function(this, "Function", {
code: Lambda.Code.fromAsset(filesLambda),
handler: "index.run",
runtime: Lambda.Runtime.NODEJS_12_X,
memorySize: 1024,
timeout: CDK.Duration.seconds(3),
layers: [layer],
});
new CDK.CfnOutput(this, "FunctionName", {
value: lambda.functionName,
});
}
}
-
December 17 th, 2020
486 Words
To decouple services on AWS, it’s a common pattern to use Amazon SQS and Amazon SNS. With AWS Key Management Service, you can encrypt the messages stored in the SNS topic and SQS queue. For the AWS Cloud Development Kit using TypeScript, you can easily create an architecture for secure message processing.
-
December 11 th, 2020
270 Words
With AWS CloudFormation StackSets you can deploy a CloudFormation template to multiple AWS Accounts or AWS Regions. You can use the AWS Management Console, the AWS CLI, or CloudFormation to use StackSets. Before using StackSets, you need to configure specific IAM roles to be used with CloudFormation StackSets.
-
December 7 th, 2020
380 Words
Most people only use Amazon API Gateway as an HTTP interface to invoke AWS Lambda functions. But, the service has way more to offer. For example, you can easily create an HTTP interface for nearly any AWS Service; not only AWS Lambda. Based on the previous post, on how to create a State Machine with AWS Step Functions and AWS Cloud Development Kit, this post describes how to create an HTTP interface to start an execution of a State Machine using the AWS CDK.
-
December 7 th, 2020
327 Words
Most people know Amazon API Gateway from using it to build HTTP interfaces for AWS Lambda functions. But, in general, you can use API Gateway to call a variety AWS APIs using HTTPS. This post shows how to create an HTTPS interface for Amazon SQS using the AWS Cloud Development Kit.
-
December 6 th, 2020
435 Words
With AWS Step Functions, you can easily orchestrate serverless functions and sequence them with other AWS services to a bundle application. You can create AWS Step Functions with CloudFormation, the AWS Cloud Development Kit, or - of course - using the visual interface available in the AWS Management Console. This post shows how to orchestrate AWS Lambda functions to a simple State Machine using AWS Step Functions.
-
December 6 th, 2020
463 Words
Using the AWS Cloud Development Kit, deploying a AWS Lambda function using Docker container images is pure gold. The installation of dependencies for Lambda functions always stressed me out. Regardless of using Node.js or Python, managing dependencies for AWS Lambda was never fun.
-
December 5 th, 2020
195 Words
The AWS Cloud Development Kit supports building docker images for AWS Lambda. With the most recent version, the CDK builds your docker images if needed and can push the image directly to AWS Elastic Container Registry. Personally, I think this is a great feature. With supporting docker images, AWS Lambda has immutable deployment artifacts!