Class FunctionBase
- All Implemented Interfaces:
IResource
,IClientVpnConnectionHandler
,IConnectable
,IGrantable
,IFunction
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
- Direct Known Subclasses:
Function
,QualifiedFunctionBase
,SingletonFunction
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IClientVpnConnectionHandler
IClientVpnConnectionHandler.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.lambda.IFunction
IFunction.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
FunctionBase
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
FunctionBase
(software.amazon.jsii.JsiiObjectRef objRef) protected
FunctionBase
(software.constructs.Construct scope, String id) protected
FunctionBase
(software.constructs.Construct scope, String id, ResourceProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventSource
(IEventSource source) Adds an event source to this function.addEventSourceMapping
(String id, EventSourceMappingOptions options) Adds an event source that maps to this AWS Lambda function.Adds a url to this lambda function.addFunctionUrl
(FunctionUrlOptions options) Adds a url to this lambda function.void
addPermission
(String id, Permission permission) Adds a permission to the Lambda resource policy.void
addToRolePolicy
(PolicyStatement statement) Adds a statement to the IAM role assumed by the instance.void
Configures options for asynchronous invocation.void
considerWarningOnInvokeFunctionPermissions
(software.constructs.Construct scope, String action) A warning will be added to functions under the following conditions: - permissions that includelambda:InvokeFunction
are added to the unqualified function.abstract Architecture
The architecture of this Lambda Function.protected abstract Boolean
Whether the addPermission() call adds any permissions.Access the Connections object.abstract String
The ARN fo the function.abstract String
The name of the function.abstract IPrincipal
The principal this Lambda Function is running as.Whether or not this Lambda function was bound to a VPC.The$LATEST
version of this function.abstract software.constructs.Node
The construct node where permissions are attached.The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().abstract IRole
getRole()
The IAM role associated with this function.grantInvoke
(IGrantable grantee) Grant the given identity permissions to invoke this Lambda.grantInvokeCompositePrincipal
(CompositePrincipal compositePrincipal) Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.grantInvokeLatestVersion
(IGrantable grantee) Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.grantInvokeUrl
(IGrantable grantee) Grant the given identity permissions to invoke this Lambda Function URL.grantInvokeVersion
(IGrantable grantee, IVersion version) Grant the given identity permissions to invoke the given version of this Lambda.Return the given named metric for this Function.metric
(String metricName, MetricOptions props) Return the given named metric for this Function.How long execution of this Lambda takes.metricDuration
(MetricOptions props) How long execution of this Lambda takes.How many invocations of this Lambda fail.metricErrors
(MetricOptions props) How many invocations of this Lambda fail.How often this Lambda is invoked.metricInvocations
(MetricOptions props) How often this Lambda is invoked.How often this Lambda is throttled.metricThrottles
(MetricOptions props) How often this Lambda is throttled.protected void
warnInvokeFunctionPermissions
(software.constructs.Construct scope) Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
FunctionBase
protected FunctionBase(software.amazon.jsii.JsiiObjectRef objRef) -
FunctionBase
protected FunctionBase(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
FunctionBase
@Stability(Stable) protected FunctionBase(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable ResourceProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
-
-
FunctionBase
@Stability(Stable) protected FunctionBase(@NotNull software.constructs.Construct scope, @NotNull String id) - Parameters:
scope
- This parameter is required.id
- This parameter is required.
-
-
Method Details
-
addEventSource
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));
- Specified by:
addEventSource
in interfaceIFunction
- Parameters:
source
- This parameter is required.
-
addEventSourceMapping
@Stability(Stable) @NotNull public EventSourceMapping addEventSourceMapping(@NotNull String id, @NotNull EventSourceMappingOptions options) Adds an event source that maps to this AWS Lambda function.- Specified by:
addEventSourceMapping
in interfaceIFunction
- Parameters:
id
- This parameter is required.options
- This parameter is required.
-
addFunctionUrl
Adds a url to this lambda function.- Specified by:
addFunctionUrl
in interfaceIFunction
- Parameters:
options
-
-
addFunctionUrl
Adds a url to this lambda function.- Specified by:
addFunctionUrl
in interfaceIFunction
-
addPermission
Adds a permission to the Lambda resource policy.- Specified by:
addPermission
in interfaceIFunction
- Parameters:
id
- The id for the permission construct. This parameter is required.permission
- The permission to grant to this Lambda function. This parameter is required.- See Also:
-
addToRolePolicy
Adds a statement to the IAM role assumed by the instance.- Specified by:
addToRolePolicy
in interfaceIFunction
- Parameters:
statement
- This parameter is required.
-
configureAsyncInvoke
Configures options for asynchronous invocation.- Specified by:
configureAsyncInvoke
in interfaceIFunction
- Parameters:
options
- This parameter is required.
-
considerWarningOnInvokeFunctionPermissions
@Stability(Stable) public void considerWarningOnInvokeFunctionPermissions(@NotNull software.constructs.Construct scope, @NotNull String action) A warning will be added to functions under the following conditions: - permissions that includelambda:InvokeFunction
are added to the unqualified function.- function.currentVersion is invoked before or after the permission is created.
This applies only to permissions on Lambda functions, not versions or aliases. This function is overridden as a noOp for QualifiedFunctionBase.
- Parameters:
scope
- This parameter is required.action
- This parameter is required.
-
grantInvoke
Grant the given identity permissions to invoke this Lambda.- Specified by:
grantInvoke
in interfaceIFunction
- Parameters:
grantee
- This parameter is required.
-
grantInvokeCompositePrincipal
@Stability(Stable) @NotNull public List<Grant> grantInvokeCompositePrincipal(@NotNull CompositePrincipal compositePrincipal) Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.- Specified by:
grantInvokeCompositePrincipal
in interfaceIFunction
- Parameters:
compositePrincipal
- This parameter is required.
-
grantInvokeLatestVersion
Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.- Specified by:
grantInvokeLatestVersion
in interfaceIFunction
- Parameters:
grantee
- This parameter is required.
-
grantInvokeUrl
Grant the given identity permissions to invoke this Lambda Function URL.- Specified by:
grantInvokeUrl
in interfaceIFunction
- Parameters:
grantee
- This parameter is required.
-
grantInvokeVersion
@Stability(Stable) @NotNull public Grant grantInvokeVersion(@NotNull IGrantable grantee, @NotNull IVersion version) Grant the given identity permissions to invoke the given version of this Lambda.- Specified by:
grantInvokeVersion
in interfaceIFunction
- Parameters:
grantee
- This parameter is required.version
- This parameter is required.
-
metric
@Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props) Return the given named metric for this Function. -
metric
Return the given named metric for this Function. -
metricDuration
How long execution of this Lambda takes.Average over 5 minutes
- Specified by:
metricDuration
in interfaceIFunction
- Parameters:
props
-
-
metricDuration
How long execution of this Lambda takes.Average over 5 minutes
- Specified by:
metricDuration
in interfaceIFunction
-
metricErrors
How many invocations of this Lambda fail.Sum over 5 minutes
- Specified by:
metricErrors
in interfaceIFunction
- Parameters:
props
-
-
metricErrors
How many invocations of this Lambda fail.Sum over 5 minutes
- Specified by:
metricErrors
in interfaceIFunction
-
metricInvocations
How often this Lambda is invoked.Sum over 5 minutes
- Specified by:
metricInvocations
in interfaceIFunction
- Parameters:
props
-
-
metricInvocations
How often this Lambda is invoked.Sum over 5 minutes
- Specified by:
metricInvocations
in interfaceIFunction
-
metricThrottles
How often this Lambda is throttled.Sum over 5 minutes
- Specified by:
metricThrottles
in interfaceIFunction
- Parameters:
props
-
-
metricThrottles
How often this Lambda is throttled.Sum over 5 minutes
- Specified by:
metricThrottles
in interfaceIFunction
-
warnInvokeFunctionPermissions
@Stability(Stable) protected void warnInvokeFunctionPermissions(@NotNull software.constructs.Construct scope) - Parameters:
scope
- This parameter is required.
-
getArchitecture
The architecture of this Lambda Function.- Specified by:
getArchitecture
in interfaceIFunction
-
getCanCreatePermissions
Whether the addPermission() call adds any permissions.True for new Lambdas, false for version $LATEST and imported Lambdas from different accounts.
-
getConnections
Access the Connections object.Will fail if not a VPC-enabled Lambda Function
- Specified by:
getConnections
in interfaceIConnectable
-
getFunctionArn
The ARN fo the function.- Specified by:
getFunctionArn
in interfaceIClientVpnConnectionHandler
- Specified by:
getFunctionArn
in interfaceIFunction
-
getFunctionName
The name of the function.- Specified by:
getFunctionName
in interfaceIClientVpnConnectionHandler
- Specified by:
getFunctionName
in interfaceIFunction
-
getGrantPrincipal
The principal this Lambda Function is running as.- Specified by:
getGrantPrincipal
in interfaceIGrantable
-
getIsBoundToVpc
Whether or not this Lambda function was bound to a VPC.If this is is
false
, trying to access theconnections
object will fail.- Specified by:
getIsBoundToVpc
in interfaceIFunction
-
getLatestVersion
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.- Specified by:
getLatestVersion
in interfaceIFunction
-
getPermissionsNode
@Stability(Stable) @NotNull public abstract software.constructs.Node getPermissionsNode()The construct node where permissions are attached.- Specified by:
getPermissionsNode
in interfaceIFunction
-
getResourceArnsForGrantInvoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().- Specified by:
getResourceArnsForGrantInvoke
in interfaceIFunction
-
getRole
The IAM role associated with this function.Undefined if the function was imported without a role.
-