fn Submodule
Constructs
FailedInvocations
A dead-letter queue for Lambda invocations that failed, and an alarm for it.
Async invocations and stream event sources send their failure records here. The alarm goes to ALARM while the queue holds any messages.
Initializers
import { fn } from 'shady-island'
new fn.FailedInvocations(scope: Construct, id: string, props?: FailedInvocationsProps)
| Name | Type | Description |
|---|---|---|
scope |
constructs.Construct |
- The scope in which to define this construct. |
id |
string |
- The scoped construct ID. |
props |
FailedInvocationsProps |
- Initialization properties for this construct. |
scopeRequired
- Type: constructs.Construct
The scope in which to define this construct.
idRequired
- Type: string
The scoped construct ID.
propsOptional
- Type: FailedInvocationsProps
Initialization properties for this construct.
Methods
| Name | Description |
|---|---|
toString |
Returns a string representation of this construct. |
with |
Applies one or more mixins to this construct. |
capture |
Sends a Lambda function’s failed async invocations to the queue. |
toString
public toString(): string
Returns a string representation of this construct.
with
public with(mixins: ...IMixin[]): IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
mixinsRequired
- Type: …constructs.IMixin[]
The mixins to apply.
capture
public capture(fn: IFunction, options?: CaptureOptions): void
Sends a Lambda function’s failed async invocations to the queue.
fnRequired
- Type: aws-cdk-lib.aws_lambda.IFunction
The function, invoked asynchronously by S3, SNS, or another Lambda.
optionsOptional
- Type: CaptureOptions
Configuration options for the async invocation.
Static Functions
| Name | Description |
|---|---|
isConstruct |
Checks if x is a construct. |
isConstruct
import { fn } from 'shady-island'
fn.FailedInvocations.isConstruct(x: any)
Checks if x is a construct.
Use this method instead of instanceof to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct in each copy of the constructs library
is seen as a different class, and an instance of one class will not test as
instanceof the other class. npm install will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof will behave
unpredictably. It is safest to avoid using instanceof, and using
this type-testing method instead.
xRequired
- Type: any
Any object.
Properties
| Name | Type | Description |
|---|---|---|
node |
constructs.Node |
The tree node. |
alarm |
aws-cdk-lib.aws_cloudwatch.Alarm |
The alarm on visible messages in the queue. |
eventSourceDlq |
aws-cdk-lib.aws_lambda.IEventSourceDlq |
The destination to pass as onFailure to a stream event source. |
queue |
aws-cdk-lib.aws_sqs.IQueue |
The dead-letter queue. |
nodeRequired
public readonly node: Node;
- Type: constructs.Node
The tree node.
alarmRequired
public readonly alarm: Alarm;
- Type: aws-cdk-lib.aws_cloudwatch.Alarm
The alarm on visible messages in the queue.
eventSourceDlqRequired
public readonly eventSourceDlq: IEventSourceDlq;
- Type: aws-cdk-lib.aws_lambda.IEventSourceDlq
The destination to pass as onFailure to a stream event source.
Example
const failures = new FailedInvocations(this, "FailedInvocations");
fn.addEventSource(
new DynamoEventSource(table, {
startingPosition: StartingPosition.TRIM_HORIZON,
retryAttempts: 10,
onFailure: failures.eventSourceDlq,
})
);
queueRequired
public readonly queue: IQueue;
- Type: aws-cdk-lib.aws_sqs.IQueue
The dead-letter queue.
Structs
CaptureOptions
Options for capturing a function’s failed async invocations.
Initializer
import { fn } from 'shady-island'
const captureOptions: fn.CaptureOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
maxEventAge |
aws-cdk-lib.Duration |
The longest time Lambda keeps an event before giving up on it. |
retryAttempts |
number |
How many times Lambda retries a failed invocation. |
maxEventAgeOptional
public readonly maxEventAge: Duration;
- Type: aws-cdk-lib.Duration
- Default: 6 hours
The longest time Lambda keeps an event before giving up on it.
retryAttemptsOptional
public readonly retryAttempts: number;
- Type: number
- Default: 2
How many times Lambda retries a failed invocation.
FailedInvocationsProps
Constructor properties for FailedInvocations.
Initializer
import { fn } from 'shady-island'
const failedInvocationsProps: fn.FailedInvocationsProps = { ... }
Properties
| Name | Type | Description |
|---|---|---|
alarmDescription |
string |
The alarm’s description. |
alarmPeriod |
aws-cdk-lib.Duration |
How long the queue must hold messages before the alarm goes off. |
queue |
aws-cdk-lib.aws_sqs.IQueue |
An existing queue to alarm on, instead of creating one. |
queueProps |
aws-cdk-lib.aws_sqs.QueueProps |
Properties for the new queue, such as fifo or encryptionMasterKey. |
alarmDescriptionOptional
public readonly alarmDescription: string;
- Type: string
- Default: a description naming the queue
The alarm’s description.
alarmPeriodOptional
public readonly alarmPeriod: Duration;
- Type: aws-cdk-lib.Duration
- Default: 5 minutes
How long the queue must hold messages before the alarm goes off.
queueOptional
public readonly queue: IQueue;
- Type: aws-cdk-lib.aws_sqs.IQueue
- Default: a new queue built from
queueProps
An existing queue to alarm on, instead of creating one.
Example
const failures = new FailedInvocations(this, "FailedInvocations", {
queue: Queue.fromQueueArn(this, "Queue", deadLetterQueueArn),
});
queuePropsOptional
public readonly queueProps: QueueProps;
- Type: aws-cdk-lib.aws_sqs.QueueProps
- Default: SSL enforced, 14-day retention, CDK’s default SSE-SQS encryption
Properties for the new queue, such as fifo or encryptionMasterKey.
Example
const failures = new FailedInvocations(this, "FailedInvocations", {
queueProps: {
encryption: QueueEncryption.KMS,
encryptionMasterKey: key,
retentionPeriod: Duration.days(7),
},
});
PowertoolsLayerOptions
Options for calling the PowertoolsLayer methods.
Initializer
import { fn } from 'shady-island'
const powertoolsLayerOptions: fn.PowertoolsLayerOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
layerVersion |
number |
The version of the Lambda Layer desired. |
version |
string |
The version of Powertools desired. |
layerVersionOptional
public readonly layerVersion: number;
- Type: number
The version of the Lambda Layer desired.
Overrides {@link version}.
versionOptional
public readonly version: string;
- Type: string
- Default: “latest”
The version of Powertools desired.
Ignored if you specify layerVersion.
PowertoolsPythonOptions
Options for calling the PowertoolsLayer.forPythonV3 method.
Initializer
import { fn } from 'shady-island'
const powertoolsPythonOptions: fn.PowertoolsPythonOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
layerVersion |
number |
The version of the Lambda Layer desired. |
version |
string |
The version of Powertools desired. |
pythonVersion |
string |
The Python version (e.g. 3.10, 3.14). |
architecture |
aws-cdk-lib.aws_lambda.Architecture |
The CPU architecture for the Lambda function. |
layerVersionOptional
public readonly layerVersion: number;
- Type: number
The version of the Lambda Layer desired.
Overrides {@link version}.
versionOptional
public readonly version: string;
- Type: string
- Default: “latest”
The version of Powertools desired.
Ignored if you specify layerVersion.
pythonVersionRequired
public readonly pythonVersion: string;
- Type: string
The Python version (e.g. 3.10, 3.14).
architectureOptional
public readonly architecture: Architecture;
- Type: aws-cdk-lib.aws_lambda.Architecture
- Default: Architecture.X86_64
The CPU architecture for the Lambda function.
PowertoolsTypeScriptOptions
Options for calling the PowertoolsLayer.forTypeScriptV2 method.
Initializer
import { fn } from 'shady-island'
const powertoolsTypeScriptOptions: fn.PowertoolsTypeScriptOptions = { ... }
Properties
| Name | Type | Description |
|---|---|---|
layerVersion |
number |
The version of the Lambda Layer desired. |
version |
string |
The version of Powertools desired. |
layerVersionOptional
public readonly layerVersion: number;
- Type: number
The version of the Lambda Layer desired.
Overrides {@link version}.
versionOptional
public readonly version: string;
- Type: string
- Default: “latest”
The version of Powertools desired.
Ignored if you specify layerVersion.
Classes
PowertoolsLayer
Provides Lambda Layers for Powertools.
PowertoolsLayer.forTypeScriptV2(scope);
PowertoolsLayer.forTypeScriptV2(scope, { version: "2.34.0" });
PowertoolsLayer.forTypeScriptV2(scope, { layerVersion: 49 });
PowertoolsLayer.forPythonV3(scope, { pythonVersion: "3.14" });
PowertoolsLayer.forPythonV3(scope, { pythonVersion: "3.14", architecture: Architecture.ARM_64 });
PowertoolsLayer.forPythonV3(scope, { pythonVersion: "3.14", version: "3.31.1" });
PowertoolsLayer.forPythonV3(scope, { pythonVersion: "3.14", layerVersion: 36 });
Initializers
import { fn } from 'shady-island'
new fn.PowertoolsLayer()
| Name | Type | Description | | — | — | — |
Static Functions
| Name | Description |
|---|---|
forPythonV3 |
Get the Lambda Layer for Python V3. |
forTypeScriptV2 |
Get the Lambda Layer for TypeScript V2. |
forPythonV3
import { fn } from 'shady-island'
fn.PowertoolsLayer.forPythonV3(scope: Construct, options: PowertoolsPythonOptions)
Get the Lambda Layer for Python V3.
If you supply neither “version” nor “layerVersion”, the latest possible version of the Layer is returned by looking it up in SSM Parameter Store.
If you supply the “version” option, the Layer is returned by looking it up in SSM Parameter Store.
If you supply the “layerVersion” option, SSM is not involved.
scopeRequired
- Type: constructs.Construct
The parent scope.
optionsRequired
- Type: PowertoolsPythonOptions
The configuration options.
forTypeScriptV2
import { fn } from 'shady-island'
fn.PowertoolsLayer.forTypeScriptV2(scope: Construct, options?: PowertoolsTypeScriptOptions)
Get the Lambda Layer for TypeScript V2.
If you supply neither “version” nor “layerVersion”, the latest possible version of the Layer is returned by looking it up in SSM Parameter Store.
If you supply the “version” option, the Layer is returned by looking it up in SSM Parameter Store.
If you supply the “layerVersion” option, SSM is not involved.
scopeRequired
- Type: constructs.Construct
The parent scope.
optionsOptional
The configuration options.