Class EdgeFunction
A Lambda@Edge function.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.CloudFront.Experimental
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class EdgeFunction : Resource, IVersion, IFunction, IResource, IConnectable, IGrantable
Syntax (vb)
Public Class EdgeFunction
Inherits Resource
Implements IVersion, IFunction, IResource, IConnectable, IGrantable
Remarks
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.
Resource: AWS::Lambda::Function
ExampleMetadata: infused
Examples
Bucket myBucket;
// A Lambda@Edge function added to default behavior of a Distribution
// and triggered on every request
var myFunc = new Experimental.EdgeFunction(this, "MyFunction", new EdgeFunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromAsset(Join(__dirname, "lambda-handler"))
});
new Distribution(this, "myDist", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = new S3Origin(myBucket),
EdgeLambdas = new [] { new EdgeLambda {
FunctionVersion = myFunc.CurrentVersion,
EventType = LambdaEdgeEventType.VIEWER_REQUEST
} }
}
});
Synopsis
Constructors
EdgeFunction(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
EdgeFunction(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
EdgeFunction(Construct, String, IEdgeFunctionProps) |
Properties
Architecture | The system architectures compatible with this lambda function. |
Connections | Not supported. |
CurrentVersion | Convenience method to make |
EdgeArn | The ARN of the version for Lambda@Edge. |
FunctionArn | The ARN of the function. |
FunctionName | The name of the function. |
GrantPrincipal | The principal to grant permissions to. |
IsBoundToVpc | Whether or not this Lambda function was bound to a VPC. |
Lambda | The underlying AWS Lambda function. |
LatestVersion | The |
PermissionsNode | The construct node where permissions are attached. |
ResourceArnsForGrantInvoke | The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). |
Role | The IAM role associated with this function. |
Version | The most recently deployed version of this function. |
Methods
AddAlias(String, IAliasOptions) | Defines an alias for this version. |
AddEventSource(IEventSource) | Adds an event source to this function. |
AddEventSourceMapping(String, IEventSourceMappingOptions) | Adds an event source that maps to this AWS Lambda function. |
AddFunctionUrl(IFunctionUrlOptions) | Adds a url to this lambda function. |
AddPermission(String, IPermission) | Adds a permission to the Lambda resource policy. |
AddToRolePolicy(PolicyStatement) | Adds a statement to the IAM role assumed by the instance. |
ConfigureAsyncInvoke(IEventInvokeConfigOptions) | Configures options for asynchronous invocation. |
GrantInvoke(IGrantable) | Grant the given identity permissions to invoke this Lambda. |
GrantInvokeCompositePrincipal(CompositePrincipal) | Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. |
GrantInvokeLatestVersion(IGrantable) | Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda. |
GrantInvokeUrl(IGrantable) | Grant the given identity permissions to invoke this Lambda Function URL. |
GrantInvokeVersion(IGrantable, IVersion) | Grant the given identity permissions to invoke the given version of this Lambda. |
Metric(String, IMetricOptions) | Return the given named metric for this Lambda Return the given named metric for this Function. |
MetricDuration(IMetricOptions) | Metric for the Duration of this Lambda How long execution of this Lambda takes. |
MetricErrors(IMetricOptions) | How many invocations of this Lambda fail. |
MetricInvocations(IMetricOptions) | Metric for the number of invocations of this Lambda How often this Lambda is invoked. |
MetricThrottles(IMetricOptions) | Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled. |
Constructors
EdgeFunction(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected EdgeFunction(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
EdgeFunction(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected EdgeFunction(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
EdgeFunction(Construct, String, IEdgeFunctionProps)
public EdgeFunction(Construct scope, string id, IEdgeFunctionProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IEdgeFunctionProps
Properties
Architecture
The system architectures compatible with this lambda function.
public virtual Architecture Architecture { get; }
Property Value
Connections
Not supported.
public virtual Connections_ Connections { get; }
Property Value
Remarks
Connections are only applicable to VPC-enabled functions.
CurrentVersion
Convenience method to make EdgeFunction
conform to the same interface as Function
.
public virtual IVersion CurrentVersion { get; }
Property Value
EdgeArn
The ARN of the version for Lambda@Edge.
public virtual string EdgeArn { get; }
Property Value
System.String
FunctionArn
The ARN of the function.
public virtual string FunctionArn { get; }
Property Value
System.String
FunctionName
The name of the function.
public virtual string FunctionName { get; }
Property Value
System.String
GrantPrincipal
The principal to grant permissions to.
public virtual IPrincipal GrantPrincipal { get; }
Property Value
IsBoundToVpc
Whether or not this Lambda function was bound to a VPC.
public virtual bool IsBoundToVpc { get; }
Property Value
System.Boolean
Remarks
If this is is false
, trying to access the connections
object will fail.
Lambda
The underlying AWS Lambda function.
public virtual IFunction Lambda { get; }
Property Value
LatestVersion
The $LATEST
version of this function.
public virtual IVersion LatestVersion { get; }
Property Value
Remarks
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.
PermissionsNode
The construct node where permissions are attached.
public virtual Node PermissionsNode { get; }
Property Value
Constructs.Node
ResourceArnsForGrantInvoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
public virtual string[] ResourceArnsForGrantInvoke { get; }
Property Value
System.String[]
Remarks
This property is for cdk modules to consume only. You should not need to use this property. Instead, use grantInvoke() directly.
Role
Version
The most recently deployed version of this function.
public virtual string Version { get; }
Property Value
System.String
Methods
AddAlias(String, IAliasOptions)
Defines an alias for this version.
public virtual Alias AddAlias(string aliasName, IAliasOptions options = null)
Parameters
- aliasName System.String
- options IAliasOptions
Returns
AddEventSource(IEventSource)
Adds an event source to this function.
public virtual void AddEventSource(IEventSource source)
Parameters
- source IEventSource
AddEventSourceMapping(String, IEventSourceMappingOptions)
Adds an event source that maps to this AWS Lambda function.
public virtual EventSourceMapping AddEventSourceMapping(string id, IEventSourceMappingOptions options)
Parameters
- id System.String
- options IEventSourceMappingOptions
Returns
AddFunctionUrl(IFunctionUrlOptions)
Adds a url to this lambda function.
public virtual FunctionUrl AddFunctionUrl(IFunctionUrlOptions options = null)
Parameters
- options IFunctionUrlOptions
Returns
AddPermission(String, IPermission)
Adds a permission to the Lambda resource policy.
public virtual void AddPermission(string id, IPermission permission)
Parameters
- id System.String
- permission IPermission
AddToRolePolicy(PolicyStatement)
Adds a statement to the IAM role assumed by the instance.
public virtual void AddToRolePolicy(PolicyStatement statement)
Parameters
- statement PolicyStatement
ConfigureAsyncInvoke(IEventInvokeConfigOptions)
Configures options for asynchronous invocation.
public virtual void ConfigureAsyncInvoke(IEventInvokeConfigOptions options)
Parameters
- options IEventInvokeConfigOptions
GrantInvoke(IGrantable)
Grant the given identity permissions to invoke this Lambda.
public virtual Grant GrantInvoke(IGrantable identity)
Parameters
- identity IGrantable
Returns
GrantInvokeCompositePrincipal(CompositePrincipal)
Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
public virtual Grant[] GrantInvokeCompositePrincipal(CompositePrincipal compositePrincipal)
Parameters
- compositePrincipal CompositePrincipal
Returns
Grant[]
GrantInvokeLatestVersion(IGrantable)
Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.
public virtual Grant GrantInvokeLatestVersion(IGrantable identity)
Parameters
- identity IGrantable
Returns
GrantInvokeUrl(IGrantable)
Grant the given identity permissions to invoke this Lambda Function URL.
public virtual Grant GrantInvokeUrl(IGrantable identity)
Parameters
- identity IGrantable
Returns
GrantInvokeVersion(IGrantable, IVersion)
Grant the given identity permissions to invoke the given version of this Lambda.
public virtual Grant GrantInvokeVersion(IGrantable identity, IVersion version)
Parameters
- identity IGrantable
- version IVersion
Returns
Metric(String, IMetricOptions)
Return the given named metric for this Lambda Return the given named metric for this Function.
public virtual Metric Metric(string metricName, IMetricOptions props = null)
Parameters
- metricName System.String
- props IMetricOptions
Returns
MetricDuration(IMetricOptions)
Metric for the Duration of this Lambda How long execution of this Lambda takes.
public virtual Metric MetricDuration(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Average over 5 minutes
MetricErrors(IMetricOptions)
How many invocations of this Lambda fail.
public virtual Metric MetricErrors(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Sum over 5 minutes
MetricInvocations(IMetricOptions)
Metric for the number of invocations of this Lambda How often this Lambda is invoked.
public virtual Metric MetricInvocations(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Sum over 5 minutes
MetricThrottles(IMetricOptions)
Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled.
public virtual Metric MetricThrottles(IMetricOptions props = null)
Parameters
- props IMetricOptions
Returns
Remarks
Sum over 5 minutes