@Generated(value="jsii-pacmak/1.50.0 (build d1830a4)", date="2022-01-11T17:58:48.884Z") @Stability(value=Stable) public class EdgeFunction extends Resource implements IVersion
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_12_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();
| Modifier and Type | Class and Description |
|---|---|
static class |
EdgeFunction.Builder
A fluent builder for
EdgeFunction. |
software.amazon.jsii.JsiiObject.InitializationModeIVersion.Jsii$Default, IVersion.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
|
EdgeFunction(software.constructs.Construct scope,
String id,
EdgeFunctionProps props) |
protected |
EdgeFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
EdgeFunction(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
Alias |
addAlias(String aliasName)
Defines an alias for this version.
|
Alias |
addAlias(String aliasName,
AliasOptions options)
Defines an alias for this version.
|
void |
addEventSource(IEventSource source)
Adds an event source to this function.
|
EventSourceMapping |
addEventSourceMapping(String id,
EventSourceMappingOptions options)
Adds an event source that maps to this AWS 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 |
configureAsyncInvoke(EventInvokeConfigOptions options)
Configures options for asynchronous invocation.
|
Architecture |
getArchitecture()
The system architectures compatible with this lambda function.
|
Connections |
getConnections()
Not supported.
|
IVersion |
getCurrentVersion()
Convenience method to make `EdgeFunction` conform to the same interface as `Function`.
|
String |
getEdgeArn()
The ARN of the version for Lambda@Edge.
|
String |
getFunctionArn()
The ARN of the function.
|
String |
getFunctionName()
The name of the function.
|
IPrincipal |
getGrantPrincipal()
The principal to grant permissions to.
|
Boolean |
getIsBoundToVpc()
Whether or not this Lambda function was bound to a VPC.
|
IFunction |
getLambda()
The underlying AWS Lambda function.
|
IVersion |
getLatestVersion()
The `$LATEST` version of this function.
|
ConstructNode |
getPermissionsNode()
The construct node where permissions are attached.
|
IRole |
getRole()
The IAM role associated with this function.
|
String |
getVersion()
The most recently deployed version of this function.
|
Grant |
grantInvoke(IGrantable identity)
Grant the given identity permissions to invoke this Lambda.
|
Metric |
metric(String metricName)
Return the given named metric for this Lambda Return the given named metric for this Function.
|
Metric |
metric(String metricName,
MetricOptions props)
Return the given named metric for this Lambda Return the given named metric for this Function.
|
Metric |
metricDuration()
Metric for the Duration of this Lambda How long execution of this Lambda takes.
|
Metric |
metricDuration(MetricOptions props)
Metric for the Duration of this Lambda How long execution of this Lambda takes.
|
Metric |
metricErrors()
How many invocations of this Lambda fail.
|
Metric |
metricErrors(MetricOptions props)
How many invocations of this Lambda fail.
|
Metric |
metricInvocations()
Metric for the number of invocations of this Lambda How often this Lambda is invoked.
|
Metric |
metricInvocations(MetricOptions props)
Metric for the number of invocations of this Lambda How often this Lambda is invoked.
|
Metric |
metricThrottles()
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.
|
Metric |
metricThrottles(MetricOptions props)
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourcegetNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validatejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyRemovalPolicy, getEnv, getStackgetNodeprotected EdgeFunction(software.amazon.jsii.JsiiObjectRef objRef)
protected EdgeFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public EdgeFunction(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
EdgeFunctionProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable) @NotNull public Alias addAlias(@NotNull String aliasName, @Nullable AliasOptions options)
@Stability(value=Stable) @NotNull public Alias addAlias(@NotNull String aliasName)
@Stability(value=Stable)
public void addEventSource(@NotNull
IEventSource source)
addEventSource in interface IFunctionsource - This parameter is required.@Stability(value=Stable) @NotNull public EventSourceMapping addEventSourceMapping(@NotNull String id, @NotNull EventSourceMappingOptions options)
addEventSourceMapping in interface IFunctionid - This parameter is required.options - This parameter is required.@Stability(value=Stable)
public void addPermission(@NotNull
String id,
@NotNull
Permission permission)
addPermission in interface IFunctionid - This parameter is required.permission - This parameter is required.@Stability(value=Stable)
public void addToRolePolicy(@NotNull
PolicyStatement statement)
addToRolePolicy in interface IFunctionstatement - This parameter is required.@Stability(value=Stable)
public void configureAsyncInvoke(@NotNull
EventInvokeConfigOptions options)
configureAsyncInvoke in interface IFunctionoptions - This parameter is required.@Stability(value=Stable) @NotNull public Grant grantInvoke(@NotNull IGrantable identity)
grantInvoke in interface IFunctionidentity - This parameter is required.@Stability(value=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.
@Stability(value=Stable) @NotNull public Metric metric(@NotNull String metricName)
Return the given named metric for this Lambda Return the given named metric for this Function.
@Stability(value=Stable) @NotNull public Metric metricDuration(@Nullable MetricOptions props)
Average over 5 minutes Metric for the Duration of this Lambda How long execution of this Lambda takes.
Average over 5 minutes
metricDuration in interface IFunctionprops - @Stability(value=Stable) @NotNull public Metric metricDuration()
Average over 5 minutes Metric for the Duration of this Lambda How long execution of this Lambda takes.
Average over 5 minutes
metricDuration in interface IFunction@Stability(value=Stable) @NotNull public Metric metricErrors(@Nullable MetricOptions props)
Sum over 5 minutes
metricErrors in interface IFunctionprops - @Stability(value=Stable) @NotNull public Metric metricErrors()
Sum over 5 minutes
metricErrors in interface IFunction@Stability(value=Stable) @NotNull public Metric metricInvocations(@Nullable MetricOptions props)
Sum over 5 minutes Metric for the number of invocations of this Lambda How often this Lambda is invoked.
Sum over 5 minutes
metricInvocations in interface IFunctionprops - @Stability(value=Stable) @NotNull public Metric metricInvocations()
Sum over 5 minutes Metric for the number of invocations of this Lambda How often this Lambda is invoked.
Sum over 5 minutes
metricInvocations in interface IFunction@Stability(value=Stable) @NotNull public Metric metricThrottles(@Nullable MetricOptions props)
Sum over 5 minutes Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.
Sum over 5 minutes
metricThrottles in interface IFunctionprops - @Stability(value=Stable) @NotNull public Metric metricThrottles()
Sum over 5 minutes Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.
Sum over 5 minutes
metricThrottles in interface IFunction@Stability(value=Stable) @NotNull public Architecture getArchitecture()
getArchitecture in interface IFunction@Stability(value=Stable) @NotNull public Connections getConnections()
Connections are only applicable to VPC-enabled functions.
getConnections in interface IConnectable@Stability(value=Stable) @NotNull public IVersion getCurrentVersion()
@Stability(value=Stable) @NotNull public String getEdgeArn()
getEdgeArn in interface IVersion@Stability(value=Stable) @NotNull public String getFunctionArn()
getFunctionArn in interface IFunction@Stability(value=Stable) @NotNull public String getFunctionName()
getFunctionName in interface IFunction@Stability(value=Stable) @NotNull public IPrincipal getGrantPrincipal()
getGrantPrincipal in interface IGrantable@Stability(value=Stable) @NotNull public Boolean getIsBoundToVpc()
If this is is false, trying to access the connections object will fail.
getIsBoundToVpc in interface IFunction@Stability(value=Stable) @NotNull public IFunction getLambda()
@Stability(value=Stable) @NotNull public IVersion getLatestVersion()
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.
getLatestVersion in interface IFunction@Stability(value=Stable) @NotNull public ConstructNode getPermissionsNode()
getPermissionsNode in interface IFunction@Stability(value=Stable) @NotNull public String getVersion()
getVersion in interface IVersionCopyright © 2022. All rights reserved.