customres

package
v0.0.0-...-fa2a7d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package customres allows you to write custom provisioning logic in templates that AWS CloudFormation runs anytime you create, update, or delete stacks.

Take a tour at https://github.com/eawsy/aws-cloudformation-go-customres

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleLambda

func HandleLambda(raw json.RawMessage, ctx *runtime.Context) (interface{}, error)

HandleLambda dispatches the request to the matching custom resource handler. If no handler is registered for the requested custom resource, then an error is returned to AWS CloudFormation.

For detailed information about the incoming raw request, outgoing raw response and eventual errors, refer to the AWS CloudWatch Logs stream of the AWS Lambda function.

func NewPhysicalResourceID

func NewPhysicalResourceID(evt *cloudformationevt.Event) string

NewPhysicalResourceID generates an AWS CloudFormation like unique physical resource id of the forme "StackName-LogicalResourceID-RandomID".

func Register

func Register(name string, handler Handler)

Register registers the handler for the given custom resource. If a handler already exists for the custom resource, Register panics.

Custom resource type names can include alphanumeric characters and the following characters: _@- You can specify a custom resource type name up to a maximum length of 60 characters. Example: MyCompany@MyCustomResource

Types

type Handler

type Handler interface {
	// Create can either return a physical id and optionaly a map of name-value
	// pairs, or an error, in which case AWS CloudFormation fails the resource
	// creation.
	//
	// The physical id is a name or a unique identifier that corresponds to the
	// physical instance id of the custom resource. See NewPhysicalResourceID, for
	// a strong and unique identifier.
	// The map of name-value pairs can be accessed by name in the template
	// with Fn::GetAtt intrinsic function.
	// If an error is returned, AWS CloudFormation recognizes the failure and
	// reacts accordingly. The detailed information about the error will be
	// written in the Lambda function's AWS CloudWatch Logs stream.
	Create(*cloudformationevt.Event, *runtime.Context) (string, interface{}, error)

	// Update can either return a physical id and optionaly a map of name-value
	// pairs, or an error, in which case AWS CloudFormation fails the resource
	// update.
	//
	// The physical id is usually the same as the one returned in response to the
	// resource creation. However, you can also update custom resources that
	// requires a replacement of the underlying physical resource. In this case,
	// the new custom resource must send a new physical id. When AWS
	// CloudFormation receives the response, it compares the PhysicalResourceID
	// between the old and new custom resources. If they are different,
	// AWS CloudFormation recognizes the update as a replacement and send a delete
	// request to the old resource.
	// Notice also that the returned map of name-value pairs must contain all the
	// pairs returned in response to the resource creation, with updated values;
	// otherwise Fn::GetAtt intrinsic functions fails.
	Update(*cloudformationevt.Event, *runtime.Context) (string, interface{}, error)

	// Delete can optionaly return an error, in which case AWS CloudFormation
	// fails the resource deletion.
	Delete(*cloudformationevt.Event, *runtime.Context) error
}

Handler responds to a Lambda invocation whenever a custom resource is created, updated, or deleted.

If any sub handler panics, it is automatically recovered, stack trace is logged in AWS CloudWatch Logs stream and AWS CloudFormation is informed and reacts accordingly.

type LambdaHandler

type LambdaHandler func(json.RawMessage, *runtime.Context) (interface{}, error)

LambdaHandler responds to a Lambda function invocation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL