Interface IFunction
Inherited Members
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IFunction : IResource, IConnectable, IGrantable
Syntax (vb)
Public Interface IFunction
Inherits IResource, IConstruct, IDependable, IConnectable, IGrantable
Synopsis
Properties
Architecture | The system architectures compatible with this lambda function. |
FunctionArn | The ARN of the function. |
FunctionName | The name of the function. |
IsBoundToVpc | Whether or not this Lambda function was bound to a VPC. |
LatestVersion | The |
PermissionsNode | The construct node where permissions are attached. |
ResourceArnsForGrantInvoke | The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). |
Role | The IAM role associated with this function. |
Methods
AddEventSource(IEventSource) | Adds an event source to this function. |
AddEventSourceMapping(String, IEventSourceMappingOptions) | Adds an event source that maps to this AWS Lambda function. |
AddFunctionUrl(IFunctionUrlOptions) | Adds a url to this lambda function. |
AddPermission(String, IPermission) | Adds a permission to the Lambda resource policy. |
AddToRolePolicy(PolicyStatement) | Adds a statement to the IAM role assumed by the instance. |
ConfigureAsyncInvoke(IEventInvokeConfigOptions) | Configures options for asynchronous invocation. |
GrantInvoke(IGrantable) | Grant the given identity permissions to invoke this Lambda. |
GrantInvokeCompositePrincipal(CompositePrincipal) | Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. |
GrantInvokeLatestVersion(IGrantable) | Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda. |
GrantInvokeUrl(IGrantable) | Grant the given identity permissions to invoke this Lambda Function URL. |
GrantInvokeVersion(IGrantable, IVersion) | Grant the given identity permissions to invoke the given version of this Lambda. |
Metric(String, IMetricOptions) | Return the given named metric for this Lambda Return the given named metric for this Function. |
MetricDuration(IMetricOptions) | Metric for the Duration of this Lambda How long execution of this Lambda takes. |
MetricErrors(IMetricOptions) | How many invocations of this Lambda fail. |
MetricInvocations(IMetricOptions) | Metric for the number of invocations of this Lambda How often this Lambda is invoked. |
MetricThrottles(IMetricOptions) | Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled. |
Properties
Architecture
The system architectures compatible with this lambda function.
Architecture Architecture { get; }
Property Value
FunctionArn
The ARN of the function.
string FunctionArn { get; }
Property Value
System.String
Remarks
Attribute: true
FunctionName
The name of the function.
string FunctionName { get; }
Property Value
System.String
Remarks
Attribute: true
IsBoundToVpc
Whether or not this Lambda function was bound to a VPC.
bool IsBoundToVpc { get; }
Property Value
System.Boolean
Remarks
If this is is false
, trying to access the connections
object will fail.
LatestVersion
The $LATEST
version of this function.
IVersion LatestVersion { get; }
Property Value
Remarks
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.
PermissionsNode
The construct node where permissions are attached.
Node PermissionsNode { get; }
Property Value
Constructs.Node
ResourceArnsForGrantInvoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
string[] ResourceArnsForGrantInvoke { get; }
Property Value
System.String[]
Remarks
This property is for cdk modules to consume only. You should not need to use this property. Instead, use grantInvoke() directly.
Role
Methods
AddEventSource(IEventSource)
Adds an event source to this function.
void AddEventSource(IEventSource source)
Parameters
- source IEventSource
Remarks
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));
AddEventSourceMapping(String, IEventSourceMappingOptions)
Adds an event source that maps to this AWS Lambda function.
EventSourceMapping AddEventSourceMapping(string id, IEventSourceMappingOptions options)
Parameters
- id System.String
construct ID.
- options IEventSourceMappingOptions
mapping options.
Returns
AddFunctionUrl(IFunctionUrlOptions)
Adds a url to this lambda function.
FunctionUrl AddFunctionUrl(IFunctionUrlOptions options = null)
Parameters
- options IFunctionUrlOptions
Returns
AddPermission(String, IPermission)
Adds a permission to the Lambda resource policy.
void AddPermission(string id, IPermission permission)
Parameters
- id System.String
The id for the permission construct.
- permission IPermission
The permission to grant to this Lambda function.
Remarks
See: Permission for details.
AddToRolePolicy(PolicyStatement)
Adds a statement to the IAM role assumed by the instance.
void AddToRolePolicy(PolicyStatement statement)
Parameters
- statement PolicyStatement
ConfigureAsyncInvoke(IEventInvokeConfigOptions)
Configures options for asynchronous invocation.
void ConfigureAsyncInvoke(IEventInvokeConfigOptions options)
Parameters
- options IEventInvokeConfigOptions
GrantInvoke(IGrantable)
Grant the given identity permissions to invoke this Lambda.
Grant GrantInvoke(IGrantable identity)
Parameters
- identity IGrantable
Returns
GrantInvokeCompositePrincipal(CompositePrincipal)
Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
Grant[] GrantInvokeCompositePrincipal(CompositePrincipal compositePrincipal)
Parameters
- compositePrincipal CompositePrincipal
Returns
Grant[]
GrantInvokeLatestVersion(IGrantable)
Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.
Grant GrantInvokeLatestVersion(IGrantable identity)
Parameters
- identity IGrantable
Returns
GrantInvokeUrl(IGrantable)
Grant the given identity permissions to invoke this Lambda Function URL.
Grant GrantInvokeUrl(IGrantable identity)
Parameters
- identity IGrantable
Returns
GrantInvokeVersion(IGrantable, IVersion)
Grant the given identity permissions to invoke the given version of this Lambda.
Grant GrantInvokeVersion(IGrantable identity, IVersion version)
Parameters
- identity IGrantable
- version IVersion
Returns
Metric(String, IMetricOptions)
Return the given named metric for this Lambda Return the given named metric for this Function.
Metric Metric(string metricName, IMetricOptions props = null)
Parameters
- metricName System.String
- props IMetricOptions
Returns
MetricDuration(IMetricOptions)
Metric for the Duration of this Lambda How long execution of this Lambda takes.
Metric MetricDuration(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Average over 5 minutes
Default: average over 5 minutes
MetricErrors(IMetricOptions)
How many invocations of this Lambda fail.
Metric MetricErrors(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Sum over 5 minutes
MetricInvocations(IMetricOptions)
Metric for the number of invocations of this Lambda How often this Lambda is invoked.
Metric MetricInvocations(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Sum over 5 minutes
Default: sum over 5 minutes
MetricThrottles(IMetricOptions)
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.
Metric MetricThrottles(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Sum over 5 minutes
Default: sum over 5 minutes