Skip to content
v2.273.0

AWS Lambda Layer with AWS CLI ​

This module exports a single class called AwsCliLayer which is a lambda.Layer that bundles the AWS CLI.

Any Lambda Function that uses this layer must use a Python 3.x runtime.

Usage:

ts
// AwsCliLayer bundles the AWS CLI in a lambda layer
import { AwsCliLayer } from 'aws-cdk-lib/lambda-layer-awscli';

declare const fn: lambda.Function;
fn.addLayers(new AwsCliLayer(this, 'AwsCliLayer'));
python
# AwsCliLayer bundles the AWS CLI in a lambda layer
from aws_cdk.lambda_layer_awscli import AwsCliLayer

# fn: lambda.Function

fn.add_layers(AwsCliLayer(self, "AwsCliLayer"))
java
// AwsCliLayer bundles the AWS CLI in a lambda layer
import software.amazon.awscdk.lambdalayer.awscli.AwsCliLayer;

Function fn;

fn.addLayers(new AwsCliLayer(this, "AwsCliLayer"));
csharp
// AwsCliLayer bundles the AWS CLI in a lambda layer
using Amazon.CDK.LambdaLayer.AwsCli;

Function fn;

fn.AddLayers(new AwsCliLayer(this, "AwsCliLayer"));
go
// AwsCliLayer bundles the AWS CLI in a lambda layer
import "github.com/aws/aws-cdk-go/awscdk"

var fn Function

fn.AddLayers(awscdk.NewAwsCliLayer(this, jsii.String("AwsCliLayer")))

The CLI will be installed under /opt/awscli/aws.

Alternatives ​

This module bundles AWS cli v1. To use AWS cli v2, you can use the external module awscdk-asset-awscli.

Types ​

NameKindSummary
AwsCliLayerConstruct (L2)An AWS Lambda layer that includes the AWS CLI.