interface IAlias
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Lambda.IAlias |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awslambda#IAlias |
Java | software.amazon.awscdk.services.lambda.IAlias |
Python | aws_cdk.aws_lambda.IAlias |
TypeScript (source) | aws-cdk-lib » aws_lambda » IAlias |
Implemented by
Alias
Obtainable from
Alias
.fromAliasAttributes()
Properties
Name | Type | Description |
---|---|---|
alias | string | Name of this alias. |
architecture | Architecture | The system architectures compatible with this lambda function. |
connections | Connections | The network connections associated with this resource. |
env | Resource | The environment this resource belongs to. |
function | string | The ARN of the function. |
function | string | The name of the function. |
grant | IPrincipal | The principal to grant permissions to. |
is | boolean | Whether or not this Lambda function was bound to a VPC. |
latest | IVersion | The $LATEST version of this function. |
node | Node | The tree node. |
permissions | Node | The construct node where permissions are attached. |
resource | string[] | The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). |
stack | Stack | The stack in which this resource is defined. |
version | IVersion | The underlying Lambda function version. |
role? | IRole | The IAM role associated with this function. |
aliasName
Type:
string
Name of this alias.
architecture
Type:
Architecture
The system architectures compatible with this lambda function.
connections
Type:
Connections
The network connections associated with this resource.
env
Type:
Resource
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.
functionArn
Type:
string
The ARN of the function.
functionName
Type:
string
The name of the function.
grantPrincipal
Type:
IPrincipal
The principal to grant permissions to.
isBoundToVpc
Type:
boolean
Whether or not this Lambda function was bound to a VPC.
If this is is false
, trying to access the connections
object will fail.
latestVersion
Type:
IVersion
The $LATEST
version of this function.
Note that this is reference to a non-specific AWS Lambda version, which means the function this version refers to can return different results in different invocations.
To obtain a reference to an explicit version which references the current
function configuration, use lambdaFunction.currentVersion
instead.
node
Type:
Node
The tree node.
permissionsNode
Type:
Node
The construct node where permissions are attached.
resourceArnsForGrantInvoke
Type:
string[]
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
This property is for cdk modules to consume only. You should not need to use this property. Instead, use grantInvoke() directly.
stack
Type:
Stack
The stack in which this resource is defined.
version
Type:
IVersion
The underlying Lambda function version.
role?
Type:
IRole
(optional)
The IAM role associated with this function.
Methods
Name | Description |
---|---|
add | Adds an event source to this function. |
add | Adds an event source that maps to this AWS Lambda function. |
add | Adds a url to this lambda function. |
add | Adds a permission to the Lambda resource policy. |
add | Adds a statement to the IAM role assumed by the instance. |
apply | Apply the given removal policy to this resource. |
configure | Configures options for asynchronous invocation. |
grant | Grant the given identity permissions to invoke this Lambda. |
grant | Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. |
grant | Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda. |
grant | Grant the given identity permissions to invoke this Lambda Function URL. |
grant | Grant the given identity permissions to invoke the given version of this Lambda. |
metric(metricName, props?) | Return the given named metric for this Lambda Return the given named metric for this Function. |
metric | Metric for the Duration of this Lambda How long execution of this Lambda takes. |
metric | How many invocations of this Lambda fail. |
metric | Metric for the number of invocations of this Lambda How often this Lambda is invoked. |
metric | Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled. |
EventSource(source)
addpublic addEventSource(source: IEventSource): void
Parameters
- source
IEvent
Source
Adds an event source to this function.
Event sources are implemented in the aws-cdk-lib/aws-lambda-event-sources module.
The following example adds an SQS Queue as an event source:
import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
myFunction.addEventSource(new SqsEventSource(myQueue));
EventSourceMapping(id, options)
addpublic addEventSourceMapping(id: string, options: EventSourceMappingOptions): EventSourceMapping
Parameters
- id
string
— construct ID. - options
Event
— mapping options.Source Mapping Options
Returns
Adds an event source that maps to this AWS Lambda function.
FunctionUrl(options?)
addpublic addFunctionUrl(options?: FunctionUrlOptions): FunctionUrl
Parameters
- options
Function
Url Options
Returns
Adds a url to this lambda function.
Permission(id, permission)
addpublic addPermission(id: string, permission: Permission): void
Parameters
- id
string
— The id for the permission construct. - permission
Permission
— The permission to grant to this Lambda function.
Adds a permission to the Lambda resource policy.
See also: [Permission for details.](Permission for details.)
ToRolePolicy(statement)
addpublic addToRolePolicy(statement: PolicyStatement): void
Parameters
- statement
Policy
Statement
Adds a statement to the IAM role assumed by the instance.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
).
AsyncInvoke(options)
configurepublic configureAsyncInvoke(options: EventInvokeConfigOptions): void
Parameters
- options
Event
Invoke Config Options
Configures options for asynchronous invocation.
Invoke(identity)
grantpublic grantInvoke(identity: IGrantable): Grant
Parameters
- identity
IGrantable
Returns
Grant the given identity permissions to invoke this Lambda.
InvokeCompositePrincipal(compositePrincipal)
grantpublic grantInvokeCompositePrincipal(compositePrincipal: CompositePrincipal): Grant[]
Parameters
- compositePrincipal
Composite
Principal
Returns
Grant
[]
Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
InvokeLatestVersion(identity)
grantpublic grantInvokeLatestVersion(identity: IGrantable): Grant
Parameters
- identity
IGrantable
Returns
Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.
InvokeUrl(identity)
grantpublic grantInvokeUrl(identity: IGrantable): Grant
Parameters
- identity
IGrantable
Returns
Grant the given identity permissions to invoke this Lambda Function URL.
InvokeVersion(identity, version)
grantpublic grantInvokeVersion(identity: IGrantable, version: IVersion): Grant
Parameters
- identity
IGrantable
- version
IVersion
Returns
Grant the given identity permissions to invoke the given version of this Lambda.
metric(metricName, props?)
public metric(metricName: string, props?: MetricOptions): Metric
Parameters
- metricName
string
- props
Metric
Options
Returns
Return the given named metric for this Lambda Return the given named metric for this Function.
Duration(props?)
metricpublic metricDuration(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
Metric for the Duration of this Lambda How long execution of this Lambda takes.
Average over 5 minutes
Errors(props?)
metricpublic metricErrors(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
How many invocations of this Lambda fail.
Sum over 5 minutes
Invocations(props?)
metricpublic metricInvocations(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
Metric for the number of invocations of this Lambda How often this Lambda is invoked.
Sum over 5 minutes
Throttles(props?)
metricpublic metricThrottles(props?: MetricOptions): Metric
Parameters
- props
Metric
Options
Returns
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.
Sum over 5 minutes