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 ILambda
Declaration
protected ALambdaCustomResourceFunction(ILambdaJsonSerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
ILambda |
serializer | Custom implementation of ILambda |
ALambdaCustomResourceFunction(ILambdaJsonSerializer, ILambdaFunctionDependencyProvider)
Initializes a new ALambdaCustomResourceFunction<TProperties, TAttributes> instance using a
custom implementation of ILambda
Declaration
protected ALambdaCustomResourceFunction(ILambdaJsonSerializer serializer, ILambdaFunctionDependencyProvider provider)
Parameters
Type | Name | Description |
---|---|---|
ILambda |
serializer | Custom implementation of ILambda |
ILambda |
provider | Custom implementation of ILambda |
Properties
LambdaSerializer
An instance of ILambda
Declaration
protected ILambdaJsonSerializer LambdaSerializer { get; }
Property Value
Type | Description |
---|---|
ILambda |
The ILambda |
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. |
message | The response message. |
Returns
Type | Description |
---|---|
System. |
Nothing. See remarks. |
Remarks
This method never returns as the abort exception is thrown immediately. The System.
Examples
throw Abort("value for property X is invalid");
HandleFailedInitializationAsync(Stream)
The Handle
Declaration
protected override async Task HandleFailedInitializationAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System. |
stream | The stream with the request payload. |
Returns
Type | Description |
---|---|
System. |
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. |
cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System. |
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. |
cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System. |
The task object representing the asynchronous operation. |
ProcessMessageStreamAsync(Stream)
The Process
Declaration
public sealed override async Task<Stream> ProcessMessageStreamAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System. |
stream | The stream with the request payload. |
Returns
Type | Description |
---|---|
System. |
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. |
cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
System. |
The task object representing the asynchronous operation. |