Class EdgeFunction
- All Implemented Interfaces:
IConstruct
,IDependable
,IResource
,IConnectable
,IGrantable
,IFunction
,IVersion
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
Convenience resource for requesting a Lambda function in the 'us-east-1' region for use with Lambda@Edge. Implements several restrictions enforced by Lambda@Edge.
Note that this construct requires that the 'us-east-1' region has been bootstrapped. See https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html or 'cdk bootstrap --help' for options.
Example:
Bucket myBucket; // A Lambda@Edge function added to default behavior of a Distribution // and triggered on every request EdgeFunction myFunc = EdgeFunction.Builder.create(this, "MyFunction") .runtime(Runtime.NODEJS_14_X) .handler("index.handler") .code(Code.fromAsset(join(__dirname, "lambda-handler"))) .build(); Distribution.Builder.create(this, "myDist") .defaultBehavior(BehaviorOptions.builder() .origin(new S3Origin(myBucket)) .edgeLambdas(List.of(EdgeLambda.builder() .functionVersion(myFunc.getCurrentVersion()) .eventType(LambdaEdgeEventType.VIEWER_REQUEST) .build())) .build()) .build();
-
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.core.IConstruct
IConstruct.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.core.IResource
IResource.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.lambda.IVersion
IVersion.Jsii$Default, IVersion.Jsii$Proxy
-
Constructor Summary
ModifierConstructorDescriptionprotected
EdgeFunction
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
EdgeFunction
(software.amazon.jsii.JsiiObjectRef objRef) EdgeFunction
(software.constructs.Construct scope, String id, EdgeFunctionProps props) -
Method Summary
Modifier and TypeMethodDescriptionDefines an alias for this version.addAlias
(String aliasName, AliasOptions options) Defines an alias for this version.void
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.The system architectures compatible with this lambda function.Not supported.Convenience method to makeEdgeFunction
conform to the same interface asFunction
.The ARN of the version for Lambda@Edge.The ARN of the function.The name of the function.The principal to grant permissions to.Whether or not this Lambda function was bound to a VPC.The underlying AWS Lambda function.The$LATEST
version of this function.The construct node where permissions are attached.The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().getRole()
The IAM role associated with this function.The most recently deployed version of this function.grantInvoke
(IGrantable identity) Grant the given identity permissions to invoke this Lambda.grantInvokeUrl
(IGrantable identity) Grant the given identity permissions to invoke this Lambda Function URL.Return the given named metric for this Lambda Return the given named metric for this Function.metric
(String metricName, MetricOptions props) Return the given named metric for this Lambda Return the given named metric for this Function.Metric for the Duration of this Lambda How long execution of this Lambda takes.metricDuration
(MetricOptions props) Metric for the Duration of this Lambda How long execution of this Lambda takes.How many invocations of this Lambda fail.metricErrors
(MetricOptions props) How many invocations of this Lambda fail.Metric for the number of invocations of this Lambda How often this Lambda is invoked.metricInvocations
(MetricOptions props) Metric for the number of invocations of this Lambda How often this Lambda is invoked.Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.metricThrottles
(MetricOptions props) Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
Methods inherited from class software.constructs.Construct
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.amazon.awscdk.core.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
EdgeFunction
protected EdgeFunction(software.amazon.jsii.JsiiObjectRef objRef) -
EdgeFunction
protected EdgeFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
EdgeFunction
@Stability(Stable) public EdgeFunction(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull EdgeFunctionProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
addAlias
@Stability(Stable) @NotNull public Alias addAlias(@NotNull String aliasName, @Nullable AliasOptions options) Defines an alias for this version. -
addAlias
Defines an alias for this version. -
addEventSource
Adds an event source to this function.- 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
- This parameter is required.permission
- 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.
-
grantInvoke
Grant the given identity permissions to invoke this Lambda.- Specified by:
grantInvoke
in interfaceIFunction
- Parameters:
identity
- This parameter is required.
-
grantInvokeUrl
Grant the given identity permissions to invoke this Lambda Function URL.- Specified by:
grantInvokeUrl
in interfaceIFunction
- Parameters:
identity
- This parameter is required.
-
metric
@Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props) Return the given named metric for this Lambda Return the given named metric for this Function. -
metric
Return the given named metric for this Lambda Return the given named metric for this Function. -
metricDuration
Metric for the Duration of this Lambda How long execution of this Lambda takes.Average over 5 minutes
- Specified by:
metricDuration
in interfaceIFunction
- Parameters:
props
-
-
metricDuration
Metric for the Duration of this Lambda 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
Metric for the number of invocations of this Lambda How often this Lambda is invoked.Sum over 5 minutes
- Specified by:
metricInvocations
in interfaceIFunction
- Parameters:
props
-
-
metricInvocations
Metric for the number of invocations of this Lambda How often this Lambda is invoked.Sum over 5 minutes
- Specified by:
metricInvocations
in interfaceIFunction
-
metricThrottles
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.Sum over 5 minutes
- Specified by:
metricThrottles
in interfaceIFunction
- Parameters:
props
-
-
metricThrottles
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.Sum over 5 minutes
- Specified by:
metricThrottles
in interfaceIFunction
-
getArchitecture
The system architectures compatible with this lambda function.- Specified by:
getArchitecture
in interfaceIFunction
-
getConnections
Not supported.Connections are only applicable to VPC-enabled functions.
- Specified by:
getConnections
in interfaceIConnectable
-
getCurrentVersion
Convenience method to makeEdgeFunction
conform to the same interface asFunction
. -
getEdgeArn
The ARN of the version for Lambda@Edge.- Specified by:
getEdgeArn
in interfaceIVersion
-
getFunctionArn
The ARN of the function.- Specified by:
getFunctionArn
in interfaceIFunction
-
getFunctionName
The name of the function.- Specified by:
getFunctionName
in interfaceIFunction
-
getGrantPrincipal
The principal to grant permissions to.- 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
-
getLambda
The underlying AWS Lambda function. -
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
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().This property is for cdk modules to consume only. You should not need to use this property. Instead, use grantInvoke() directly.
- Specified by:
getResourceArnsForGrantInvoke
in interfaceIFunction
-
getVersion
The most recently deployed version of this function.- Specified by:
getVersion
in interfaceIVersion
-
getRole
The IAM role associated with this function.
-