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 ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.lambda.IVersion
IVersion.Jsii$Default, IVersion.Jsii$Proxy - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEdgeFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedEdgeFunction(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.voidaddEventSource(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.The system architectures compatible with this lambda function.Not supported.Convenience method to makeEdgeFunctionconform 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$LATESTversion 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, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
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.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods 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:
 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- 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:
 addToRolePolicyin interfaceIFunction- Parameters:
 statement- This parameter is required.
 - 
configureAsyncInvoke
Configures options for asynchronous invocation.- Specified by:
 configureAsyncInvokein interfaceIFunction- Parameters:
 options- This parameter is required.
 - 
grantInvoke
Grant the given identity permissions to invoke this Lambda.- Specified by:
 grantInvokein interfaceIFunction- Parameters:
 identity- This parameter is required.
 - 
grantInvokeUrl
Grant the given identity permissions to invoke this Lambda Function URL.- Specified by:
 grantInvokeUrlin 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:
 metricDurationin interfaceIFunction- Parameters:
 props-
 - 
metricDuration
Metric for the Duration of this Lambda 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
Metric for the number of invocations of this Lambda How often this Lambda is invoked.Sum over 5 minutes
- Specified by:
 metricInvocationsin 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:
 metricInvocationsin interfaceIFunction
 - 
metricThrottles
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.Sum over 5 minutes
- Specified by:
 metricThrottlesin 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:
 metricThrottlesin interfaceIFunction
 - 
getArchitecture
The system architectures compatible with this lambda function.- Specified by:
 getArchitecturein interfaceIFunction
 - 
getConnections
Not supported.Connections are only applicable to VPC-enabled functions.
- Specified by:
 getConnectionsin interfaceIConnectable
 - 
getCurrentVersion
Convenience method to makeEdgeFunctionconform to the same interface asFunction. - 
getEdgeArn
The ARN of the version for Lambda@Edge.- Specified by:
 getEdgeArnin interfaceIVersion
 - 
getFunctionArn
The ARN of the function.- Specified by:
 getFunctionArnin interfaceIFunction
 - 
getFunctionName
The name of the function.- Specified by:
 getFunctionNamein interfaceIFunction
 - 
getGrantPrincipal
The principal to grant permissions to.- 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
 - 
getLambda
The underlying AWS Lambda function. - 
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
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().This property is for cdk modules to consume only. You should not need to use this property. Instead, use grantInvoke() directly.
- Specified by:
 getResourceArnsForGrantInvokein interfaceIFunction
 - 
getVersion
The most recently deployed version of this function.- Specified by:
 getVersionin interfaceIVersion
 - 
getRole
The IAM role associated with this function. 
 -