Skip to content

Latest commit

 

History

History
816 lines (490 loc) · 31.1 KB

API.md

File metadata and controls

816 lines (490 loc) · 31.1 KB

API Reference

Constructs

LambdaPowertoolsLayer

Defines a new Lambda Layer with Powertools for AWS Lambda (Python) library.

Initializers

import { LambdaPowertoolsLayer } from 'cdk-aws-lambda-powertools-layer'

new LambdaPowertoolsLayer(scope: Construct, id: string, props?: PowertoolsLayerProps)
Name Type Description
scope constructs.Construct No description.
id string No description.
props PowertoolsLayerProps No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsOptional

Methods

Name Description
toString Returns a string representation of this construct.
applyRemovalPolicy Apply the given removal policy to this resource.
addPermission Add permission for this layer version to specific entities.

toString
public toString(): string

Returns a string representation of this construct.

applyRemovalPolicy
public applyRemovalPolicy(policy: RemovalPolicy): void

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

policyRequired
  • Type: aws-cdk-lib.RemovalPolicy

addPermission
public addPermission(id: string, permission: LayerVersionPermission): void

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.

idRequired
  • Type: string

permissionRequired
  • Type: aws-cdk-lib.aws_lambda.LayerVersionPermission

Static Functions

Name Description
isConstruct Checks if x is a construct.
isOwnedResource Returns true if the construct was created by CDK, and false otherwise.
isResource Check whether the given construct is a Resource.
fromLayerVersionArn Imports a layer version by ARN.
fromLayerVersionAttributes Imports a Layer that has been defined externally.

isConstruct
import { LambdaPowertoolsLayer } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayer.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


isOwnedResource
import { LambdaPowertoolsLayer } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayer.isOwnedResource(construct: IConstruct)

Returns true if the construct was created by CDK, and false otherwise.

constructRequired
  • Type: constructs.IConstruct

isResource
import { LambdaPowertoolsLayer } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayer.isResource(construct: IConstruct)

Check whether the given construct is a Resource.

constructRequired
  • Type: constructs.IConstruct

fromLayerVersionArn
import { LambdaPowertoolsLayer } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayer.fromLayerVersionArn(scope: Construct, id: string, layerVersionArn: string)

Imports a layer version by ARN.

Assumes it is compatible with all Lambda runtimes.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

layerVersionArnRequired
  • Type: string

fromLayerVersionAttributes
import { LambdaPowertoolsLayer } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayer.fromLayerVersionAttributes(scope: Construct, id: string, attrs: LayerVersionAttributes)

Imports a Layer that has been defined externally.

scopeRequired
  • Type: constructs.Construct

the parent Construct that will use the imported layer.


idRequired
  • Type: string

the id of the imported layer in the construct tree.


attrsRequired
  • Type: aws-cdk-lib.aws_lambda.LayerVersionAttributes

the properties of the imported layer.


Properties

Name Type Description
node constructs.Node The tree node.
env aws-cdk-lib.ResourceEnvironment The environment this resource belongs to.
stack aws-cdk-lib.Stack The stack in which this resource is defined.
layerVersionArn string The ARN of the Lambda Layer version that this Layer defines.
compatibleRuntimes aws-cdk-lib.aws_lambda.Runtime[] The runtimes compatible with this Layer.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


envRequired
public readonly env: ResourceEnvironment;
  • Type: aws-cdk-lib.ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


stackRequired
public readonly stack: Stack;
  • Type: aws-cdk-lib.Stack

The stack in which this resource is defined.


layerVersionArnRequired
public readonly layerVersionArn: string;
  • Type: string

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


compatibleRuntimesOptional
public readonly compatibleRuntimes: Runtime[];
  • Type: aws-cdk-lib.aws_lambda.Runtime[]

The runtimes compatible with this Layer.


LambdaPowertoolsLayerPythonV3

Initializers

import { LambdaPowertoolsLayerPythonV3 } from 'cdk-aws-lambda-powertools-layer'

new LambdaPowertoolsLayerPythonV3(scope: Construct, id: string, props?: PowertoolsPythonLayerProps)
Name Type Description
scope constructs.Construct No description.
id string No description.
props PowertoolsPythonLayerProps No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsOptional

Methods

Name Description
toString Returns a string representation of this construct.
applyRemovalPolicy Apply the given removal policy to this resource.
addPermission Add permission for this layer version to specific entities.

toString
public toString(): string

Returns a string representation of this construct.

applyRemovalPolicy
public applyRemovalPolicy(policy: RemovalPolicy): void

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

policyRequired
  • Type: aws-cdk-lib.RemovalPolicy

addPermission
public addPermission(id: string, permission: LayerVersionPermission): void

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.

idRequired
  • Type: string

permissionRequired
  • Type: aws-cdk-lib.aws_lambda.LayerVersionPermission

Static Functions

Name Description
isConstruct Checks if x is a construct.
isOwnedResource Returns true if the construct was created by CDK, and false otherwise.
isResource Check whether the given construct is a Resource.
fromLayerVersionArn Imports a layer version by ARN.
fromLayerVersionAttributes Imports a Layer that has been defined externally.

isConstruct
import { LambdaPowertoolsLayerPythonV3 } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayerPythonV3.isConstruct(x: any)

Checks if x is a construct.

xRequired
  • Type: any

Any object.


isOwnedResource
import { LambdaPowertoolsLayerPythonV3 } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayerPythonV3.isOwnedResource(construct: IConstruct)

Returns true if the construct was created by CDK, and false otherwise.

constructRequired
  • Type: constructs.IConstruct

isResource
import { LambdaPowertoolsLayerPythonV3 } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayerPythonV3.isResource(construct: IConstruct)

Check whether the given construct is a Resource.

constructRequired
  • Type: constructs.IConstruct

fromLayerVersionArn
import { LambdaPowertoolsLayerPythonV3 } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayerPythonV3.fromLayerVersionArn(scope: Construct, id: string, layerVersionArn: string)

Imports a layer version by ARN.

Assumes it is compatible with all Lambda runtimes.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

layerVersionArnRequired
  • Type: string

fromLayerVersionAttributes
import { LambdaPowertoolsLayerPythonV3 } from 'cdk-aws-lambda-powertools-layer'

LambdaPowertoolsLayerPythonV3.fromLayerVersionAttributes(scope: Construct, id: string, attrs: LayerVersionAttributes)

Imports a Layer that has been defined externally.

scopeRequired
  • Type: constructs.Construct

the parent Construct that will use the imported layer.


idRequired
  • Type: string

the id of the imported layer in the construct tree.


attrsRequired
  • Type: aws-cdk-lib.aws_lambda.LayerVersionAttributes

the properties of the imported layer.


Properties

Name Type Description
node constructs.Node The tree node.
env aws-cdk-lib.ResourceEnvironment The environment this resource belongs to.
stack aws-cdk-lib.Stack The stack in which this resource is defined.
layerVersionArn string The ARN of the Lambda Layer version that this Layer defines.
compatibleRuntimes aws-cdk-lib.aws_lambda.Runtime[] The runtimes compatible with this Layer.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


envRequired
public readonly env: ResourceEnvironment;
  • Type: aws-cdk-lib.ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


stackRequired
public readonly stack: Stack;
  • Type: aws-cdk-lib.Stack

The stack in which this resource is defined.


layerVersionArnRequired
public readonly layerVersionArn: string;
  • Type: string

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


compatibleRuntimesOptional
public readonly compatibleRuntimes: Runtime[];
  • Type: aws-cdk-lib.aws_lambda.Runtime[]

The runtimes compatible with this Layer.


Structs

PowertoolsLayerProps

Properties for Powertools for AWS Lambda (Python) Layer.

Initializer

import { PowertoolsLayerProps } from 'cdk-aws-lambda-powertools-layer'

const powertoolsLayerProps: PowertoolsLayerProps = { ... }

Properties

Name Type Description
compatibleArchitectures aws-cdk-lib.aws_lambda.Architecture[] The compatible architectures for the layer.
includeExtras boolean A flag for the extras dependencies (pydantic, aws-xray-sdk, etc.) This will increase the size of the layer significantly. If you don't use parsing, ignore it.
layerVersionName string the name of the layer, will be randomised if empty.
runtimeFamily aws-cdk-lib.aws_lambda.RuntimeFamily the runtime of the layer.
version string The Powertools for AWS Lambda package version from pypi repository.

compatibleArchitecturesOptional
public readonly compatibleArchitectures: Architecture[];
  • Type: aws-cdk-lib.aws_lambda.Architecture[]

The compatible architectures for the layer.


includeExtrasOptional
public readonly includeExtras: boolean;
  • Type: boolean

A flag for the extras dependencies (pydantic, aws-xray-sdk, etc.) This will increase the size of the layer significantly. If you don't use parsing, ignore it.


layerVersionNameOptional
public readonly layerVersionName: string;
  • Type: string

the name of the layer, will be randomised if empty.


runtimeFamilyOptional
public readonly runtimeFamily: RuntimeFamily;
  • Type: aws-cdk-lib.aws_lambda.RuntimeFamily

the runtime of the layer.


versionOptional
public readonly version: string;
  • Type: string

The Powertools for AWS Lambda package version from pypi repository.


PowertoolsPythonLayerProps

Defines a new Lambda Layer with Powertools for AWS Lambda (Python) library.

Initializer

import { PowertoolsPythonLayerProps } from 'cdk-aws-lambda-powertools-layer'

const powertoolsPythonLayerProps: PowertoolsPythonLayerProps = { ... }

Properties

Name Type Description
compatibleArchitectures aws-cdk-lib.aws_lambda.Architecture[] The compatible architectures for the layer.
includeExtras boolean A flag for the extras dependencies (pydantic, aws-xray-sdk, etc.) This will increase the size of the layer significantly. If you don't use parsing, ignore it.
layerVersionName string the name of the layer, will be randomised if empty.
runtimeFamily aws-cdk-lib.aws_lambda.RuntimeFamily the runtime of the layer.
version string The Powertools for AWS Lambda package version from pypi repository.
pythonVersion aws-cdk-lib.aws_lambda.Runtime The Python version for Powertools for AWS Lambda (Python) V3.

compatibleArchitecturesOptional
public readonly compatibleArchitectures: Architecture[];
  • Type: aws-cdk-lib.aws_lambda.Architecture[]

The compatible architectures for the layer.


includeExtrasOptional
public readonly includeExtras: boolean;
  • Type: boolean

A flag for the extras dependencies (pydantic, aws-xray-sdk, etc.) This will increase the size of the layer significantly. If you don't use parsing, ignore it.


layerVersionNameOptional
public readonly layerVersionName: string;
  • Type: string

the name of the layer, will be randomised if empty.


runtimeFamilyOptional
public readonly runtimeFamily: RuntimeFamily;
  • Type: aws-cdk-lib.aws_lambda.RuntimeFamily

the runtime of the layer.


versionOptional
public readonly version: string;
  • Type: string

The Powertools for AWS Lambda package version from pypi repository.


pythonVersionOptional
public readonly pythonVersion: Runtime;
  • Type: aws-cdk-lib.aws_lambda.Runtime

The Python version for Powertools for AWS Lambda (Python) V3.

Allowed values: Runtime.PYTHON_3_8 Runtime.PYTHON_3_9 Runtime.PYTHON_3_10 Runtime.PYTHON_3_11 Runtime.PYTHON_3_12