LayerVersion

class aws_cdk.aws_lambda.LayerVersion(scope, id, *, code, compatible_runtimes=None, description=None, layer_version_name=None, license=None)

Bases: aws_cdk.core.Resource

Defines a new Lambda Layer version.

__init__(scope, id, *, code, compatible_runtimes=None, description=None, layer_version_name=None, license=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • code (Code) – The content of this Layer. Using Code.fromInline is not supported.

  • compatible_runtimes (Optional[List[Runtime]]) – The runtimes compatible with this Layer. Default: - All runtimes are supported.

  • description (Optional[str]) – The description the this Lambda Layer. Default: - No description.

  • layer_version_name (Optional[str]) – The name of the layer. Default: - A name will be generated.

  • license (Optional[str]) – The SPDX licence identifier or URL to the license file for this layer. Default: - No license information will be recorded.

Return type

None

Methods

add_permission(id, *, account_id, organization_id=None)

Add permission for this layer version to specific entities.

Usage within the same account where the layer is defined is always allowed and does not require calling this method. Note that the principal that creates the Lambda function using the layer (for example, a CloudFormation changeset execution role) also needs to have the lambda:GetLayerVersion permission on the layer version.

Parameters
  • id (str) –

  • account_id (str) – The AWS Account id of the account that is authorized to use a Lambda Layer Version. The wild-card '*' can be used to grant access to “any” account (or any account in an organization when organizationId is specified).

  • organization_id (Optional[str]) – The ID of the AWS Organization to hwich the grant is restricted. Can only be specified if accountId is '*'

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

compatible_runtimes

The runtimes compatible with this Layer.

Return type

Optional[List[Runtime]]

layer_version_arn

The ARN of the Lambda Layer version that this Layer defines.

Return type

str

node

The construct tree node associated with this construct.

Return type

ConstructNode

stack

The stack in which this resource is defined.

Return type

Stack

Static Methods

classmethod from_layer_version_arn(scope, id, layer_version_arn)

Imports a layer version by ARN.

Assumes it is compatible with all Lambda runtimes.

Parameters
  • scope (Construct) –

  • id (str) –

  • layer_version_arn (str) –

Return type

ILayerVersion

classmethod from_layer_version_attributes(scope, id, *, layer_version_arn, compatible_runtimes=None)

Imports a Layer that has been defined externally.

Parameters
  • scope (Construct) – the parent Construct that will use the imported layer.

  • id (str) – the id of the imported layer in the construct tree.

  • layer_version_arn (str) – The ARN of the LayerVersion.

  • compatible_runtimes (Optional[List[Runtime]]) – The list of compatible runtimes with this Layer.

Return type

ILayerVersion

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool