cloudformationresources

package module
v0.0.0-...-a2efb8e Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2017 License: MIT Imports: 23 Imported by: 3

README

CloudFormationResources

Catalog of golang-based CloudFormation CustomResources

Adding a New Resource

  1. Create a new struct that embeds CustomResourceCommand - This struct MUST embed GoAWSCustomResource as in: type HelloWorldResource struct { GoAWSCustomResource Message string }

  2. Ensure the new type implements CustomResourceCommand by adding: - create(session *session.Session, logger *logrus.Logger) (map[string]interface{}, error) - update(session *session.Session, logger *logrus.Logger) (map[string]interface{}, error) - delete(session *session.Session, logger *logrus.Logger) (map[string]interface{}, error)

  3. Add a package level var denoting the resource type - The value MUST be generated by cloudFormationResourceType(...) to include the proper custom resource prefix. Example:

    HelloWorld = cloudFormationResourceType("HelloWorldResource")
    
  4. Add a case label in customCommandForTypeName for the custom resource type added in step 2.
    - This block is responsible for creating a new command instance and unmarshalling the properties into the type-specific values. - Assign the new command to the customCommand interface. Example:

    case HelloWorld:
      	command := HelloWorldResource{
      		GoAWSCustomResource: GoAWSCustomResource{
      			GoAWSType: resourceTypeName,
      		},
      	}
      	if nil != properties {
      		unmarshalError = json.Unmarshal([]byte(string(*properties)), &command)
      	}
      	customCommand = &command
      }
    

Documentation

Index

Constants

View Source
const (
	// CreateOperation is a request to create a resource
	// @enum CloudFormationOperation
	CreateOperation = "Create"
	// DeleteOperation is a request to delete a resource
	// @enum CloudFormationOperation
	DeleteOperation = "Delete"
	// UpdateOperation is a request to update a resource
	// @enum CloudFormationOperation
	UpdateOperation = "Update"
)
View Source
const DefaultManifestName = "MANIFEST.json"

DefaultManifestName is the name of the file that will be created at the root of the S3 bucket with user-supplied metadata

Variables

View Source
var (
	// HelloWorld is the typename for HelloWorldResource
	HelloWorld = cloudFormationResourceType("HelloWorldResource")
	// S3LambdaEventSource is the typename for S3LambdaEventSourceResource
	S3LambdaEventSource = cloudFormationResourceType("S3LambdaEventSourceResource")
	// SNSLambdaEventSource is the typename for SNSLambdaEventSourceResource
	SNSLambdaEventSource = cloudFormationResourceType("SNSLambdaEventSourceResource")
	// SESLambdaEventSource is the typename for SESLambdaEventSourceResource
	SESLambdaEventSource = cloudFormationResourceType("SESLambdaEventSourceResource")
	// CloudWatchLogsLambdaEventSource is the typename for SESLambdaEventSourceResource
	CloudWatchLogsLambdaEventSource = cloudFormationResourceType("CloudWatchLogsLambdaEventSourceResource")
	// ZipToS3Bucket is the typename for ZipToS3Bucket
	ZipToS3Bucket = cloudFormationResourceType("ZipToS3BucketResource")
)

Functions

func Handle

func Handle(request *CustomResourceRequest,
	customCreds credentials.Value,
	logger *logrus.Logger) error

Handle processes the given CustomResourceRequest value

func Run

func Run(request *UserFuncResourceRequest, logger *logrus.Logger) error

Run manages invoking a user supplied function to perform the CloudFormation resource operation. Clients do not need to implement anything cloudformationresource related.

Types

type AbstractCustomResourceRequest

type AbstractCustomResourceRequest struct {
	RequestType        string
	ResponseURL        string
	StackID            string `json:"StackId"`
	RequestID          string `json:"RequestId"`
	LogicalResourceID  string `json:"LogicalResourceId"`
	PhysicalResourceID string `json:"PhysicalResourceId"`
	LogGroupName       string `json:"logGroupName"`
	LogStreamName      string `json:"logStreamName"`
	ResourceProperties map[string]interface{}
}

AbstractCustomResourceRequest is the base structure used for CustomResourceRequests

type CloudFormationLambdaEvent

type CloudFormationLambdaEvent struct {
	RequestType           string
	ResponseURL           string
	StackID               string `json:"StackId"`
	RequestID             string `json:"RequestId"`
	ResourceType          string
	LogicalResourceID     string `json:"LogicalResourceId"`
	PhysicalResourceID    string `json:"PhysicalResourceId"`
	ResourceProperties    map[string]interface{}
	OldResourceProperties map[string]interface{}
}

CloudFormationLambdaEvent represents the event data sent during a Lambda invocation in the context of a CloudFormation operation. Ref: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html

type CloudWatchLogsLambdaEventSourceFilter

type CloudWatchLogsLambdaEventSourceFilter struct {
	Name         *gocf.StringExpr
	Pattern      *gocf.StringExpr
	LogGroupName *gocf.StringExpr
}

CloudWatchLogsLambdaEventSourceFilter represents a filter for a cloudwatchlogs stream

type CloudWatchLogsLambdaEventSourceResource

type CloudWatchLogsLambdaEventSourceResource struct {
	GoAWSCustomResource
	LambdaTargetArn *gocf.StringExpr
	Filters         []*CloudWatchLogsLambdaEventSourceFilter
	RoleARN         *gocf.StringExpr `json:",omitempty"`
}

CloudWatchLogsLambdaEventSourceResource is a simple POC showing how to create custom resources

type CustomResourceCommand

type CustomResourceCommand interface {
	// contains filtered or unexported methods
}

CustomResourceCommand defines operations that a CustomResource must implement. The return values are either operation outputs or an error value that should be used in the response to the CloudFormation AWS Lambda response.

type CustomResourceFunction

type CustomResourceFunction func(requestType string,
	stackID string,
	properties map[string]interface{},
	logger *logrus.Logger) (map[string]interface{}, error)

CustomResourceFunction defines a free function that is capable of responding to an incoming Lambda-backed CustomResource request and returning either a map of outputs or an error. It is invoked by Run().

type CustomResourceRequest

type CustomResourceRequest struct {
	AbstractCustomResourceRequest
}

CustomResourceRequest is the go representation of a CloudFormation resource request for a resource the catalog that had been previously serialized.

type GoAWSCustomResource

type GoAWSCustomResource struct {
	gocf.CloudFormationCustomResource
	GoAWSType string
}

GoAWSCustomResource is the common embedded struct for all resources defined by cloudformationresources

type HelloWorldResource

type HelloWorldResource struct {
	GoAWSCustomResource
	Message string
}

HelloWorldResource is a simple POC showing how to create custom resources

type S3LambdaEventSourceResource

type S3LambdaEventSourceResource struct {
	GoAWSCustomResource
	BucketArn       *gocf.StringExpr
	Events          []string
	LambdaTargetArn *gocf.StringExpr
	Filter          *s3.NotificationConfigurationFilter `json:"Filter,omitempty"`
}

S3LambdaEventSourceResource manages registering a Lambda function with S3 event

type SESLambdaEventSourceResource

type SESLambdaEventSourceResource struct {
	GoAWSCustomResource
	RuleSetName *gocf.StringExpr
	Rules       []*SESLambdaEventSourceResourceRule
}

SESLambdaEventSourceResource handles configuring SES configuration

type SESLambdaEventSourceResourceAction

type SESLambdaEventSourceResourceAction struct {
	ActionType       *gocf.StringExpr
	ActionProperties map[string]interface{}
}

SESLambdaEventSourceResourceAction represents an SES rule action TODO - specialized types for Actions

type SESLambdaEventSourceResourceRule

type SESLambdaEventSourceResourceRule struct {
	Name        *gocf.StringExpr
	Actions     []*SESLambdaEventSourceResourceAction
	ScanEnabled *gocf.BoolExpr `json:",omitempty"`
	Enabled     *gocf.BoolExpr `json:",omitempty"`
	Recipients  []*gocf.StringExpr
	TLSPolicy   *gocf.StringExpr `json:",omitempty"`
}

SESLambdaEventSourceResourceRule stores settings necessary to configure an SES inbound rule

type SNSLambdaEventSourceResource

type SNSLambdaEventSourceResource struct {
	GoAWSCustomResource
	LambdaTargetArn *gocf.StringExpr
	SNSTopicArn     *gocf.StringExpr
}

SNSLambdaEventSourceResource is a simple POC showing how to create custom resources

type UserFuncResourceRequest

type UserFuncResourceRequest struct {
	AbstractCustomResourceRequest
	LambdaHandler CustomResourceFunction
}

UserFuncResourceRequest is the go representation of the CloudFormation resource request which is handled by a user supplied function. The function result is used as the results for the

type ZipToS3BucketResource

type ZipToS3BucketResource struct {
	GoAWSCustomResource
	SrcBucket    *gocf.StringExpr
	SrcKeyName   *gocf.StringExpr
	DestBucket   *gocf.StringExpr
	ManifestName string
	Manifest     map[string]interface{}
}

ZipToS3BucketResource manages populating an S3 bucket with the contents of a ZIP file...

Jump to

Keyboard shortcuts

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