Interface IFunctionProps
Inherited Members
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IFunctionProps : IFunctionOptions, IEventInvokeConfigOptions
Syntax (vb)
Public Interface IFunctionProps
Inherits IFunctionOptions, IEventInvokeConfigOptions
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.Lambda;
var fn = new Function(this, "MyFunc", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromInline("exports.handler = handler.toString()")
});
var rule = new Rule(this, "rule", new RuleProps {
EventPattern = new EventPattern {
Source = new [] { "aws.ec2" }
}
});
var queue = new Queue(this, "Queue");
rule.AddTarget(new LambdaFunction(fn, new LambdaFunctionProps {
DeadLetterQueue = queue, // Optional: add a dead letter queue
MaxEventAge = Duration.Hours(2), // Optional: set the maxEventAge retry policy
RetryAttempts = 2
}));
Synopsis
Properties
Code | The source code of your Lambda function. |
Handler | The name of the method within your code that Lambda calls to execute your function. |
Runtime | The runtime environment for the Lambda function that you are uploading. |
Properties
Code
The source code of your Lambda function.
Code Code { get; }
Property Value
Remarks
You can point to a file in an Amazon Simple Storage Service (Amazon S3) bucket or specify your source code as inline text.
Handler
The name of the method within your code that Lambda calls to execute your function.
string Handler { get; }
Property Value
System.String
Remarks
The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/foundation-progmodel.html.
Use Handler.FROM_IMAGE
when defining a function from a Docker image.
NOTE: If you specify your source code as inline text by specifying the ZipFile property within the Code property, specify index.function_name as the handler.
Runtime
The runtime environment for the Lambda function that you are uploading.
Runtime Runtime { get; }
Property Value
Remarks
For valid values, see the Runtime property in the AWS Lambda Developer Guide.
Use Runtime.FROM_IMAGE
when defining a function from a Docker image.