Class FunctionBase
- All Implemented Interfaces:
IResource,IClientVpnConnectionHandler,IConnectable,IGrantable,IFunction,IFunctionRef,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.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.ec2.IClientVpnConnectionHandler
IClientVpnConnectionHandler.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.lambda.IFunction
IFunction.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFunctionBase(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedFunctionBase(software.amazon.jsii.JsiiObjectRef objRef) protectedFunctionBase(software.constructs.Construct scope, String id) protectedFunctionBase(software.constructs.Construct scope, String id, ResourceProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventSource(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.voidaddPermission(String id, Permission permission) Adds a permission to the Lambda resource policy.voidaddToRolePolicy(PolicyStatement statement) Adds a statement to the IAM role assumed by the instance.voidConfigures options for asynchronous invocation.voidconsiderWarningOnInvokeFunctionPermissions(software.constructs.Construct scope, String action) A warning will be added to functions under the following conditions: - permissions that includelambda:InvokeFunctionare added to the unqualified function.abstract ArchitectureThe architecture of this Lambda Function.protected abstract BooleanWhether the addPermission() call adds any permissions.Access the Connections object.abstract StringThe ARN fo the function.abstract StringThe name of the function.A reference to a Function resource.abstract IPrincipalThe principal this Lambda Function is running as.Whether or not this Lambda function was bound to a VPC.The$LATESTversion of this function.abstract software.constructs.NodeThe construct node where permissions are attached.The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().abstract IRolegetRole()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 voidwarnInvokeFunctionPermissions(software.constructs.Construct scope) Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStackMethods 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:
addEventSourcein 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:
addEventSourceMappingin interfaceIFunction- Parameters:
id- This parameter is required.options- This parameter is required.
-
addFunctionUrl
Adds a url to this lambda function.- Specified by:
addFunctionUrlin interfaceIFunction- Parameters:
options-
-
addFunctionUrl
Adds a url to this lambda function.- Specified by:
addFunctionUrlin interfaceIFunction
-
addPermission
Adds a permission to the Lambda resource policy.- Specified by:
addPermissionin 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:
addToRolePolicyin interfaceIFunction- Parameters:
statement- This parameter is required.
-
configureAsyncInvoke
Configures options for asynchronous invocation.- Specified by:
configureAsyncInvokein 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:InvokeFunctionare 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:
grantInvokein 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:
grantInvokeCompositePrincipalin 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:
grantInvokeLatestVersionin interfaceIFunction- Parameters:
grantee- This parameter is required.
-
grantInvokeUrl
Grant the given identity permissions to invoke this Lambda Function URL.- Specified by:
grantInvokeUrlin 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:
grantInvokeVersionin 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:
metricDurationin interfaceIFunction- Parameters:
props-
-
metricDuration
How long execution of this Lambda takes.Average over 5 minutes
- Specified by:
metricDurationin interfaceIFunction
-
metricErrors
How many invocations of this Lambda fail.Sum over 5 minutes
- Specified by:
metricErrorsin interfaceIFunction- Parameters:
props-
-
metricErrors
How many invocations of this Lambda fail.Sum over 5 minutes
- Specified by:
metricErrorsin interfaceIFunction
-
metricInvocations
How often this Lambda is invoked.Sum over 5 minutes
- Specified by:
metricInvocationsin interfaceIFunction- Parameters:
props-
-
metricInvocations
How often this Lambda is invoked.Sum over 5 minutes
- Specified by:
metricInvocationsin interfaceIFunction
-
metricThrottles
How often this Lambda is throttled.Sum over 5 minutes
- Specified by:
metricThrottlesin interfaceIFunction- Parameters:
props-
-
metricThrottles
How often this Lambda is throttled.Sum over 5 minutes
- Specified by:
metricThrottlesin 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:
getArchitecturein 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:
getConnectionsin interfaceIConnectable
-
getFunctionArn
The ARN fo the function.- Specified by:
getFunctionArnin interfaceIClientVpnConnectionHandler- Specified by:
getFunctionArnin interfaceIFunction
-
getFunctionName
The name of the function.- Specified by:
getFunctionNamein interfaceIClientVpnConnectionHandler- Specified by:
getFunctionNamein interfaceIFunction
-
getFunctionRef
A reference to a Function resource.- Specified by:
getFunctionRefin interfaceIFunctionRef
-
getGrantPrincipal
The principal this Lambda Function is running as.- Specified by:
getGrantPrincipalin interfaceIGrantable
-
getIsBoundToVpc
Whether or not this Lambda function was bound to a VPC.If this is is
false, trying to access theconnectionsobject will fail.- Specified by:
getIsBoundToVpcin interfaceIFunction
-
getLatestVersion
The$LATESTversion 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.currentVersioninstead.- Specified by:
getLatestVersionin interfaceIFunction
-
getPermissionsNode
@Stability(Stable) @NotNull public abstract software.constructs.Node getPermissionsNode()The construct node where permissions are attached.- Specified by:
getPermissionsNodein interfaceIFunction
-
getResourceArnsForGrantInvoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().- Specified by:
getResourceArnsForGrantInvokein interfaceIFunction
-
getRole
The IAM role associated with this function.Undefined if the function was imported without a role.
-