cusres

package
v0.0.0-...-50f1de2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLambdaHandler

func NewLambdaHandler(h CustomResourceHandler) func(ctx context.Context, req Request) error

NewLambdaHandler returns handler function to pass to the lambda.Start of aws-lambda-go.

func StartLambda

func StartLambda(h CustomResourceHandler)

StartLambda takes a CustomResourceHandler and starts the lambda function.

Types

type CustomResourceHandler

type CustomResourceHandler interface {
	Create(ctx context.Context, req Request) (physicalResourceID string, data interface{}, err error)
	Update(ctx context.Context, req Request) (data interface{}, err error)
	Delete(ctx context.Context, req Request) error
}

CustomResourceHandler is the interface for defining the handler called when AWS CloudFormation stack including lambda-backed custom resource is created, updated, or deleted.

Create creates the custom resource. Create returns physicalResourceID, data and err. physicalResourceID is set to PhysicalResourceId field of the custom resource response. when physicalResourceID is empty, he automatically generated id is set. The value returned as data is a value that can be obtained by Fn::GetAtt from the custom resource of template. data must be the type that can be converted to map[string]interface{}. When data has multi-level map hierarchy, it is converted into map[string]interface{} with the key name is concatenated by '.'. When err is not nil, the creation of custom resource is failed.

Update updates the custom resource. Update returns data and err. The value returned as data is a value that can be obtained by Fn::GetAtt from the custom resource of template. data must be the type that can be converted to map[string]interface{}. When data has multi-level map hierarchy, it is converted into map[string]interface{} with the key name is concatenated by '.'. When err is not nil, the updating of custom resource is failed.

Delete deletes the custom resource Delete returns err. When err is not nil, the deleting of custom resource is failed.

type Properties

type Properties map[string]interface{}

Properties represents the key-value properties field type of the Request.

func (Properties) Unmarshal

func (p Properties) Unmarshal(v interface{}) error

Unmarshal converts itsself into type of v and stores the value pointed to by v.

type Request

type Request struct {
	RequestType           RequestType `json:"RequestType,omitempty"`
	ResponseURL           string      `json:"ResponseURL,omitempty"`
	StackID               string      `json:"StackId,omitempty"`
	RequestID             string      `json:"RequestId,omitempty"`
	ResourceType          string      `json:"ResourceType,omitempty"`
	LogicalResourceID     string      `json:"LogicalResourceId,omitempty"`
	PhysicalResourceID    string      `json:"PhysicalResourceId,omitempty"`
	ResourceProperties    Properties  `json:"ResourceProperties,omitempty"`
	OldResourceProperties Properties  `json:"OldResourceProperties,omitempty"`
}

Request represents the AWS CloudFormation lambda-backed custom resource operation request. see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html.

type RequestType

type RequestType string

RequestType represents the custom resource request type. see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requesttypes.html.

const (
	// RequestTypeCreate represents request type of Create.
	RequestTypeCreate RequestType = "Create"
	// RequestTypeUpdate represents request type of Update.
	RequestTypeUpdate RequestType = "Update"
	// RequestTypeDelete represents request type of Delete.
	RequestTypeDelete RequestType = "Delete"
)

type Response

type Response struct {
	Status             ResponseStatus `json:"Status,omitempty"`
	Reason             string         `json:"Reason,omitempty"`
	StackID            string         `json:"StackId,omitempty"`
	RequestID          string         `json:"RequestId,omitempty"`
	LogicalResourceID  string         `json:"LogicalResourceId,omitempty"`
	PhysicalResourceID string         `json:"PhysicalResourceId,omitempty"`
	NoEcho             bool           `json:"NoEcho,omitempty"`
	Data               interface{}    `json:"Data,omitempty"`
}

Response represents the AWS CloudFormation lambda-backed custom resource operation response. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html

type ResponseStatus

type ResponseStatus string

ResponseStatus represents the custom resource response status.

const (
	// ResponseStatusSuccess represents request response of SUCCESS.
	ResponseStatusSuccess ResponseStatus = "SUCCESS"
	// ResponseStatusFailed represents request response of FAILED.
	ResponseStatusFailed ResponseStatus = "FAILED"
)

Jump to

Keyboard shortcuts

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