@Generated(value="jsii-pacmak/1.58.0 (build f8ba112)", date="2022-05-13T01:13:36.097Z") 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 . |
IVersion.Jsii$Default, IVersion.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
EdgeFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
EdgeFunction(software.amazon.jsii.JsiiObjectRef objRef) |
|
EdgeFunction(software.constructs.Construct scope,
java.lang.String id,
EdgeFunctionProps props) |
Modifier and Type | Method and Description |
---|---|
Alias |
addAlias(java.lang.String aliasName)
Defines an alias for this version.
|
Alias |
addAlias(java.lang.String aliasName,
AliasOptions options)
Defines an alias for this version.
|
void |
addEventSource(IEventSource source)
Adds an event source to this function.
|
EventSourceMapping |
addEventSourceMapping(java.lang.String id,
EventSourceMappingOptions options)
Adds an event source that maps to this AWS Lambda function.
|
FunctionUrl |
addFunctionUrl()
Adds a url to this lambda function.
|
FunctionUrl |
addFunctionUrl(FunctionUrlOptions options)
Adds a url to this lambda function.
|
void |
addPermission(java.lang.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`.
|
java.lang.String |
getEdgeArn()
The ARN of the version for Lambda@Edge.
|
java.lang.String |
getFunctionArn()
The ARN of the function.
|
java.lang.String |
getFunctionName()
The name of the function.
|
IPrincipal |
getGrantPrincipal()
The principal to grant permissions to.
|
java.lang.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.
|
java.util.List<java.lang.String> |
getResourceArnsForGrantInvoke()
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
|
IRole |
getRole()
The IAM role associated with this function.
|
java.lang.String |
getVersion()
The most recently deployed version of this function.
|
Grant |
grantInvoke(IGrantable identity)
Grant the given identity permissions to invoke this Lambda.
|
Grant |
grantInvokeUrl(IGrantable identity)
Grant the given identity permissions to invoke this Lambda Function URL.
|
Metric |
metric(java.lang.String metricName)
Return the given named metric for this Lambda Return the given named metric for this Function.
|
Metric |
metric(java.lang.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, isResource
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyRemovalPolicy, getEnv, getStack
getNode
protected EdgeFunction(software.amazon.jsii.JsiiObjectRef objRef)
protected EdgeFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public EdgeFunction(software.constructs.Construct scope, java.lang.String id, EdgeFunctionProps props)
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.public Alias addAlias(java.lang.String aliasName, AliasOptions options)
public Alias addAlias(java.lang.String aliasName)
public void addEventSource(IEventSource source)
addEventSource
in interface IFunction
source
- This parameter is required.public EventSourceMapping addEventSourceMapping(java.lang.String id, EventSourceMappingOptions options)
addEventSourceMapping
in interface IFunction
id
- This parameter is required.options
- This parameter is required.public FunctionUrl addFunctionUrl(FunctionUrlOptions options)
addFunctionUrl
in interface IFunction
options
- public FunctionUrl addFunctionUrl()
addFunctionUrl
in interface IFunction
public void addPermission(java.lang.String id, Permission permission)
addPermission
in interface IFunction
id
- This parameter is required.permission
- This parameter is required.for details.
public void addToRolePolicy(PolicyStatement statement)
addToRolePolicy
in interface IFunction
statement
- This parameter is required.public void configureAsyncInvoke(EventInvokeConfigOptions options)
configureAsyncInvoke
in interface IFunction
options
- This parameter is required.public Grant grantInvoke(IGrantable identity)
grantInvoke
in interface IFunction
identity
- This parameter is required.public Grant grantInvokeUrl(IGrantable identity)
grantInvokeUrl
in interface IFunction
identity
- This parameter is required.public Metric metric(java.lang.String metricName, MetricOptions props)
public Metric metric(java.lang.String metricName)
public Metric metricDuration(MetricOptions props)
Average over 5 minutes
metricDuration
in interface IFunction
props
- public Metric metricDuration()
Average over 5 minutes
metricDuration
in interface IFunction
public Metric metricErrors(MetricOptions props)
Sum over 5 minutes
metricErrors
in interface IFunction
props
- public Metric metricErrors()
Sum over 5 minutes
metricErrors
in interface IFunction
public Metric metricInvocations(MetricOptions props)
Sum over 5 minutes
metricInvocations
in interface IFunction
props
- public Metric metricInvocations()
Sum over 5 minutes
metricInvocations
in interface IFunction
public Metric metricThrottles(MetricOptions props)
Sum over 5 minutes
metricThrottles
in interface IFunction
props
- public Metric metricThrottles()
Sum over 5 minutes
metricThrottles
in interface IFunction
public Architecture getArchitecture()
getArchitecture
in interface IFunction
public Connections getConnections()
Connections are only applicable to VPC-enabled functions.
getConnections
in interface IConnectable
public IVersion getCurrentVersion()
public java.lang.String getEdgeArn()
getEdgeArn
in interface IVersion
public java.lang.String getFunctionArn()
getFunctionArn
in interface IFunction
public java.lang.String getFunctionName()
getFunctionName
in interface IFunction
public IPrincipal getGrantPrincipal()
getGrantPrincipal
in interface IGrantable
public java.lang.Boolean getIsBoundToVpc()
If this is is false
, trying to access the connections
object will fail.
getIsBoundToVpc
in interface IFunction
public IFunction getLambda()
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
public ConstructNode getPermissionsNode()
getPermissionsNode
in interface IFunction
public java.util.List<java.lang.String> getResourceArnsForGrantInvoke()
This property is for cdk modules to consume only. You should not need to use this property. Instead, use grantInvoke() directly.
getResourceArnsForGrantInvoke
in interface IFunction
public java.lang.String getVersion()
getVersion
in interface IVersion