cloudformation

package
Version: v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2016 License: BSD-2-Clause Imports: 19 Imported by: 0

README

This provides an interface for CloudFormation Custom Resources so that Empire can provision things for CloudFormation. It supports the following resources:

  • Custom::InstancePort: Allocates an instance port from the pool of instance ports.

Documentation

Index

Constants

View Source
const (
	Create = "Create"
	Update = "Update"
	Delete = "Delete"
)

Possible request types.

View Source
const (
	StatusSuccess = "SUCCESS"
	StatusFailed  = "FAILED"
)

Possible response statuses.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomResourceProvisioner

type CustomResourceProvisioner struct {
	// Root context.Context to use. If a reporter.Reporter is embedded,
	// errors generated will be reporter there. If a logger.Logger is
	// embedded, logging will be logged there.
	Context context.Context

	// The SQS queue url to listen for CloudFormation Custom Resource
	// requests.
	QueueURL string

	// Provisioners routes a custom resource to the thing that should do the
	// provisioning.
	Provisioners map[string]Provisioner
	// contains filtered or unexported fields
}

CustomResourceProvisioner polls for CloudFormation Custom Resource requests from an sqs queue, provisions them, then responds back.

func NewCustomResourceProvisioner

func NewCustomResourceProvisioner(db *sql.DB, config client.ConfigProvider) *CustomResourceProvisioner

NewCustomResourceProvisioner returns a new CustomResourceProvisioner with an sqs client configured from config.

func (*CustomResourceProvisioner) Handle

func (c *CustomResourceProvisioner) Handle(ctx context.Context, message *sqs.Message) error

Handle handles a single sqs.Message to perform the provisioning.

func (*CustomResourceProvisioner) Start

func (c *CustomResourceProvisioner) Start()

Start starts pulling requests from the queue and provisioning them.

type ECSServiceProperties

type ECSServiceProperties struct {
	ServiceName    *string
	Cluster        *string
	DesiredCount   *IntValue
	LoadBalancers  []LoadBalancer
	Role           *string
	TaskDefinition *string
}

ECSServiceProperties represents the properties for the Custom::ECSService resource.

type ECSServiceResource

type ECSServiceResource struct {
	// contains filtered or unexported fields
}

ECSServiceResource is a Provisioner that creates and updates ECS services.

func (*ECSServiceResource) Properties

func (p *ECSServiceResource) Properties() interface{}

func (*ECSServiceResource) Provision

func (p *ECSServiceResource) Provision(req Request) (string, interface{}, error)

type InstancePortsProvisioner

type InstancePortsProvisioner struct {
	// contains filtered or unexported fields
}

InstancePortsProvisioner is a Provisioner that allocates instance ports.

func (*InstancePortsProvisioner) Provision

func (p *InstancePortsProvisioner) Provision(req Request) (id string, data interface{}, err error)

type IntValue

type IntValue int64

IntValue defines an int64 type that can parse integers as strings from json. It's common to use `Ref`'s inside templates, which means the value of some properties could be a string or an integer.

func (*IntValue) UnmarshalJSON

func (i *IntValue) UnmarshalJSON(b []byte) error

func (*IntValue) Value

func (i *IntValue) Value() *int64

type LoadBalancer

type LoadBalancer struct {
	ContainerName    *string
	ContainerPort    *IntValue
	LoadBalancerName *string
}

type Message

type Message struct {
	Message string `json:"Message"`
}

Represents the body of the SQS message, which would have been received from SNS.

type Provisioner

type Provisioner interface {
	// Provision should do the appropriate provisioning, then return:
	//
	// 1. The physical id that was created, if any.
	// 2. The data to return.
	Provision(Request) (string, interface{}, error)
}

Provisioner is something that can provision custom resources.

type Request

type Request struct {
	// The request type is set by the AWS CloudFormation stack operation
	// (create-stack, update-stack, or delete-stack) that was initiated by
	// the template developer for the stack that contains the custom
	// resource.
	//
	// Must be one of: Create, Update, or Delete.
	RequestType string `json:"RequestType"`

	// The response URL identifies a pre-signed Amazon S3 bucket that
	// receives responses from the custom resource provider to AWS
	// CloudFormation.
	ResponseURL string `json:"ResponseURL"`

	// The Amazon Resource Name (ARN) that identifies the stack containing
	// the custom resource.
	//
	// Combining the StackId with the RequestId forms a value that can be
	// used to uniquely identify a request on a particular custom resource.
	StackId string `json:"StackId"`

	// A unique ID for the request.
	//
	// Combining the StackId with the RequestId forms a value that can be
	// used to uniquely identify a request on a particular custom resource.
	RequestId string `json:"RequestId"`

	// The template developer-chosen resource type of the custom resource in
	// the AWS CloudFormation template. Custom resource type names can be up
	// to 60 characters long and can include alphanumeric and the following
	// characters: _@-.
	ResourceType string `json:"ResourceType"`

	// The template developer-chosen name (logical ID) of the custom
	// resource in the AWS CloudFormation template. This is provided to
	// facilitate communication between the custom resource provider and the
	// template developer.
	LogicalResourceId string `json:"LogicalResourceId"`

	// A required custom resource provider-defined physical ID that is
	// unique for that provider.
	//
	// Always sent with Update and Delete requests; never sent with Create.
	PhysicalResourceId string `json:"PhysicalResourceId"`

	// This field contains the contents of the Properties object sent by the
	// template developer. Its contents are defined by the custom resource
	// provider.
	ResourceProperties interface{} `json:"ResourceProperties"`

	// Used only for Update requests. Contains the resource properties that
	// were declared previous to the update request.
	OldResourceProperties interface{} `json:"OldResourceProperties"`
}

Request represents a Custom Resource request.

See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html

type Response

type Response struct {
	// The status value sent by the custom resource provider in response to
	// an AWS CloudFormation-generated request.
	//
	// Must be either SUCCESS or FAILED.
	Status string `json:"Status"`

	// Describes the reason for a failure response.
	//
	// Required if Status is FAILED; optional otherwise.
	Reason string `json:"Reason"`

	// This value should be an identifier unique to the custom resource
	// vendor, and can be up to 1Kb in size. The value must be a non-empty
	// string.
	PhysicalResourceId string `json:"PhysicalResourceId"`

	// The Amazon Resource Name (ARN) that identifies the stack containing
	// the custom resource. This response value should be copied verbatim
	// from the request.
	StackId string `json:"StackId"`

	// A unique ID for the request. This response value should be copied
	// verbatim from the request.
	RequestId string `json:"RequestId"`

	// The template developer-chosen name (logical ID) of the custom
	// resource in the AWS CloudFormation template. This response value
	// should be copied verbatim from the request.
	LogicalResourceId string `json:"LogicalResourceId"`

	// Optional, custom resource provider-defined name-value pairs to send
	// with the response. The values provided here can be accessed by name
	// in the template with Fn::GetAtt.
	Data interface{} `json:"Data"`
}

Response represents the response body we send back to CloudFormation when provisioning is complete.

See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html

func NewResponseFromRequest

func NewResponseFromRequest(req Request) Response

NewResponseFromRequest initializes a new Response from a Request, filling in the required verbatim fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL