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, IFunctionRef, IVersionRef, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class EdgeFunction Inherits Resource Implements IVersion, IFunction, IResource, IConnectable, IGrantable, IFunctionRef, IVersionRef, IConstruct, IDependable, IEnvironmentAware
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(Construct, string, IEdgeFunctionProps) | A Lambda@Edge function. |
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. |
| FunctionRef | A reference to a Function resource. |
| 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 |
| PROPERTY_INJECTION_ID | Uniquely identifies this class. |
| 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. |
| VersionRef | A reference to a Version resource. |
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(Construct, string, IEdgeFunctionProps)
A Lambda@Edge function.
public EdgeFunction(Construct scope, string id, IEdgeFunctionProps props)
Parameters
- scope Construct
- id string
- props IEdgeFunctionProps
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
} }
}
});
Properties
Architecture
The system architectures compatible with this lambda function.
public virtual Architecture Architecture { get; }
Property Value
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
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
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
EdgeArn
The ARN of the version for Lambda@Edge.
public virtual string EdgeArn { get; }
Property Value
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
FunctionArn
The ARN of the function.
public virtual string FunctionArn { get; }
Property Value
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
FunctionName
The name of the function.
public virtual string FunctionName { get; }
Property Value
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
FunctionRef
A reference to a Function resource.
public virtual IFunctionReference FunctionRef { get; }
Property Value
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
GrantPrincipal
The principal to grant permissions to.
public virtual IPrincipal GrantPrincipal { get; }
Property Value
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
IsBoundToVpc
Whether or not this Lambda function was bound to a VPC.
public virtual bool IsBoundToVpc { get; }
Property Value
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
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
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.
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
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
PermissionsNode
The construct node where permissions are attached.
public virtual Node PermissionsNode { get; }
Property Value
Node
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
ResourceArnsForGrantInvoke
The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
public virtual string[] ResourceArnsForGrantInvoke { get; }
Property Value
string[]
Remarks
This property is for cdk modules to consume only. You should not need to use this property. Instead, use grantInvoke() directly.
Role
The IAM role associated with this function.
public virtual IRole? Role { get; }
Property Value
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
Version
The most recently deployed version of this function.
public virtual string Version { get; }
Property Value
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
VersionRef
A reference to a Version resource.
public virtual IVersionReference VersionRef { get; }
Property Value
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
Methods
AddAlias(string, IAliasOptions?)
Defines an alias for this version.
public virtual Alias AddAlias(string aliasName, IAliasOptions? options = null)
Parameters
- aliasName string
- options IAliasOptions
Returns
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
AddEventSource(IEventSource)
Adds an event source to this function.
public virtual void AddEventSource(IEventSource source)
Parameters
- source IEventSource
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
AddEventSourceMapping(string, IEventSourceMappingOptions)
Adds an event source that maps to this AWS Lambda function.
public virtual EventSourceMapping AddEventSourceMapping(string id, IEventSourceMappingOptions options)
Parameters
- id string
- options IEventSourceMappingOptions
Returns
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
AddFunctionUrl(IFunctionUrlOptions?)
Adds a url to this lambda function.
public virtual FunctionUrl AddFunctionUrl(IFunctionUrlOptions? options = null)
Parameters
- options IFunctionUrlOptions
Returns
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
AddPermission(string, IPermission)
Adds a permission to the Lambda resource policy.
public virtual void AddPermission(string id, IPermission permission)
Parameters
- id string
- permission IPermission
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
AddToRolePolicy(PolicyStatement)
Adds a statement to the IAM role assumed by the instance.
public virtual void AddToRolePolicy(PolicyStatement statement)
Parameters
- statement PolicyStatement
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
ConfigureAsyncInvoke(IEventInvokeConfigOptions)
Configures options for asynchronous invocation.
public virtual void ConfigureAsyncInvoke(IEventInvokeConfigOptions options)
Parameters
- options IEventInvokeConfigOptions
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
GrantInvoke(IGrantable)
Grant the given identity permissions to invoke this Lambda.
public virtual Grant GrantInvoke(IGrantable identity)
Parameters
- identity IGrantable
Returns
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
GrantInvokeCompositePrincipal(CompositePrincipal)
Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
public virtual Grant[] GrantInvokeCompositePrincipal(CompositePrincipal compositePrincipal)
Parameters
- compositePrincipal CompositePrincipal
Returns
Grant[]
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
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
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
GrantInvokeUrl(IGrantable)
Grant the given identity permissions to invoke this Lambda Function URL.
public virtual Grant GrantInvokeUrl(IGrantable identity)
Parameters
- identity IGrantable
Returns
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
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
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
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 string
- props IMetricOptions
Returns
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
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