# README
Overview
CloudFormation has a different way of responding to most events due to the way stacks execute.
It is best to catch all errors and ensure the correct response is sent to the pre-signed URL that comes with the event.
To make this easier, a wrapper exists to allow the creation of custom resources without having to handle that.
Sample Function
This sample will safely 'Echo' back anything given into the Echo parameter within the Custom Resource call.
import (
"context"
"fmt"
"github.com/aws/aws-lambda-go/cfn"
"github.com/aws/aws-lambda-go/lambda"
)
func echoResource(ctx context.Context, event cfn.Event) (physicalResourceID string, data map[string]interface{}, err error) {
v, _ := event.ResourceProperties["Echo"].(string)
data = map[string]interface{} {
"Echo": v,
}
return
}
func main() {
lambda.Start(cfn.LambdaWrap(echoResource))
}
# Functions
LambdaWrap returns a CustomResourceLambdaFunction which is something lambda.Start() will understand.
LambdaWrapSNS wraps a Lambda handler with support for SNS-based custom resources.
NewResponse creates a Response with the relevant verbatim copied data from a Event.
# Type aliases
CustomResourceFunction is a representation of the customer's Custom Resource function.
CustomResourceLambdaFunction is a standard form Lambda for a Custom Resource.
RequestType represents the types of requests that come from a CloudFormation stack being run.
SNSCustomResourceLambdaFunction is a standard form Lambda for a Custom Resource that is triggered via a SNS topic.
StatusType represents a CloudFormation response status.