Class ALambdaCustomResourceFunction<TProperties, TAttributes>
The ALambdaCustomResourceFunction<TProperties, TAttributes> is the abstract base class for handling custom resources in AWS CloudFormation. This class takes care of handling the communication protocol with the AWS CloudFormation service. Depending on the requested operation, the base class invokes either ProcessCreateResourceAsync(Request<TProperties>, CancellationToken), ProcessUpdateResourceAsync(Request<TProperties>, CancellationToken), or ProcessDeleteResourceAsync(Request<TProperties>, CancellationToken). In case of failure, the AWS CloudFormation service is automatically notified to avoid prolonged timeout errors during a CloudFormation stack operation.
Implements
Inherited Members
Namespace: LambdaSharp.CustomResource
Assembly: LambdaSharp.CustomResource.dll
Syntax
public abstract class ALambdaCustomResourceFunction<TProperties, TAttributes> : ALambdaFunction, ILambdaSharpLogger where TProperties : class where TAttributes : class
Type Parameters
Name | Description |
---|---|
TProperties | The request properties for the custom resource. |
TAttributes | The response attributes for the custom resource. |
Constructors
ALambdaCustomResourceFunction(ILambdaJsonSerializer)
Initializes a new ALambdaCustomResourceFunction<TProperties, TAttributes> instance using the default implementation of ILambdaFunctionDependencyProvider.
Declaration
protected ALambdaCustomResourceFunction(ILambdaJsonSerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
ILambdaJsonSerializer | serializer | Custom implementation of ILambdaJsonSerializer. |
ALambdaCustomResourceFunction(ILambdaJsonSerializer, ILambdaFunctionDependencyProvider)
Initializes a new ALambdaCustomResourceFunction<TProperties, TAttributes> instance using a custom implementation of ILambdaFunctionDependencyProvider.
Declaration
protected ALambdaCustomResourceFunction(ILambdaJsonSerializer serializer, ILambdaFunctionDependencyProvider provider)
Parameters
Type | Name | Description |
---|---|---|
ILambdaJsonSerializer | serializer | Custom implementation of ILambdaJsonSerializer. |
ILambdaFunctionDependencyProvider | provider | Custom implementation of ILambdaFunctionDependencyProvider. |
Properties
LambdaSerializer
An instance of ILambdaJsonSerializer used for serializing/deserializing JSON data.
Declaration
protected ILambdaJsonSerializer LambdaSerializer { get; }
Property Value
Type | Description |
---|---|
ILambdaJsonSerializer | The ILambdaJsonSerializer instance. |
Methods
Abort(String)
The Abort(String) stops the request processing with an error message.
Declaration
protected Exception Abort(string message)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The response message. |
Returns
Type | Description |
---|---|
System.Exception | Nothing. See remarks. |
Remarks
This method never returns as the abort exception is thrown immediately. The System.Exception instance is shown as returned to make it easier to tell the compiler the control flow.
Examples
throw Abort("value for property X is invalid");
HandleFailedInitializationAsync(Stream)
The HandleFailedInitializationAsync(Stream) method is only invoked when an error occurs during the Lambda function initialization. This method can be overridden to provide custom behavior for how to handle such failures more gracefully.
Declaration
protected override async Task HandleFailedInitializationAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream with the request payload. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The task object representing the asynchronous operation. |
Overrides
Remarks
Regardless of what this method does. Once completed, the Lambda function exits by rethrowing the original exception that occurred during initialization.
ProcessCreateResourceAsync(Request<TProperties>, CancellationToken)
The ProcessCreateResourceAsync(Request<TProperties>, CancellationToken) method is invoked when AWS CloudFormation attempts to create a custom resource.
Declaration
public abstract Task<Response<TAttributes>> ProcessCreateResourceAsync(Request<TProperties> request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Request<TProperties> | request | The CloudFormation request instance. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Response<TAttributes>> | The task object representing the asynchronous operation. |
ProcessDeleteResourceAsync(Request<TProperties>, CancellationToken)
The ProcessDeleteResourceAsync(Request<TProperties>, CancellationToken) method is invoked when AWS CloudFormation attempts to delete a custom resource.
Declaration
public abstract Task<Response<TAttributes>> ProcessDeleteResourceAsync(Request<TProperties> request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Request<TProperties> | request | The CloudFormation request instance. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Response<TAttributes>> | The task object representing the asynchronous operation. |
ProcessMessageStreamAsync(Stream)
The ProcessMessageStreamAsync(Stream) method handles the communication protocol with the AWS CloudFormation service.
Declaration
public sealed override async Task<Stream> ProcessMessageStreamAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream with the request payload. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IO.Stream> | The task object representing the asynchronous operation. |
Overrides
Remarks
This method cannot be overridden.
ProcessUpdateResourceAsync(Request<TProperties>, CancellationToken)
The ProcessUpdateResourceAsync(Request<TProperties>, CancellationToken) method is invoked when AWS CloudFormation attempts to update a custom resource.
Declaration
public abstract Task<Response<TAttributes>> ProcessUpdateResourceAsync(Request<TProperties> request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
Request<TProperties> | request | The CloudFormation request instance. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Response<TAttributes>> | The task object representing the asynchronous operation. |