cloudformation

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2018 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package cloudformation scopes CloudFormation-specific utiltities for Sparta

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudFormationResourceName added in v1.3.0

func CloudFormationResourceName(prefix string, parts ...string) string

CloudFormationResourceName returns a name suitable as a logical CloudFormation resource value. See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html for more information. The `prefix` value should provide a hint as to the resource type (eg, `SNSConfigurator`, `ImageTranscoder`). Note that the returned name is not content-addressable.

func ConvergeStackState added in v1.3.0

func ConvergeStackState(serviceName string,
	cfTemplate *gocf.Template,
	templateURL string,
	tags map[string]string,
	startTime time.Time,
	operationTimeout time.Duration,
	awsSession *session.Session,
	outputsDividerChar string,
	dividerWidth int,
	logger *logrus.Logger) (*cloudformation.Stack, error)

ConvergeStackState ensures that the serviceName converges to the template state defined by cfTemplate. This function establishes a polling loop to determine when the stack operation has completed.

func ConvertToTemplateExpression

func ConvertToTemplateExpression(templateData io.Reader,
	additionalUserTemplateProperties map[string]interface{}) (*gocf.StringExpr, error)

ConvertToTemplateExpression transforms the templateData contents into an Fn::Join- compatible representation for template serialization. The templateData contents may include both golang text/template properties and single-line JSON Fn::Join supported serializations.

Example
package main

import (
	"strings"
)

var sampleTemplate = `
BASIC_AUTH_USERNAME={{ .Username }}
CONCOURSE_BASIC_AUTH_PASSWORD={{ .Password }}
SPARTA_CICD_BINARY_PATH=/home/ubuntu/{{ .ServiceName }}.lambda.amd64
POSTGRES_ADDRESS={ "Fn::GetAtt" : [ "{{ .PostgreSQLCloudFormationResource }}" , "Endpoint.Address" ] }
`
var sampleTemplateProps = map[string]interface{}{
	"Username":                         "MyPassword",
	"Password":                         "MyPassword",
	"PostgreSQLCloudFormationResource": "DBInstance0bef52bca519f672fddf3a6e0cbf1325e0a3263c",
}

func main() {
	templateReader := strings.NewReader(sampleTemplate)
	ConvertToTemplateExpression(templateReader, sampleTemplateProps)
}
Output:

func CreateStackChangeSet added in v1.3.0

func CreateStackChangeSet(changeSetRequestName string,
	serviceName string,
	cfTemplate *gocf.Template,
	templateURL string,
	awsTags []*cloudformation.Tag,
	awsCloudFormation *cloudformation.CloudFormation,
	logger *logrus.Logger) (*cloudformation.DescribeChangeSetOutput, error)

CreateStackChangeSet returns the DescribeChangeSetOutput for a given stack transformation

func DeleteChangeSet added in v1.3.0

func DeleteChangeSet(stackName string,
	changeSetRequestName string,
	awsCloudFormation *cloudformation.CloudFormation) (*cloudformation.DeleteChangeSetOutput, error)

DeleteChangeSet is a utility function that attempts to delete an existing CloudFormation change set, with a bit of retry logic in case of EC

func DynamicValueToStringExpr added in v1.3.0

func DynamicValueToStringExpr(dynamicValue interface{}) gocf.Stringable

DynamicValueToStringExpr is a DRY function to type assert a potentiall dynamic value into a gocf.Stringable satisfying type

func ListStacks added in v1.3.0

func ListStacks(session *session.Session,
	maxReturned int,
	stackFilters ...string) ([]*cloudformation.StackSummary, error)

ListStacks returns a slice of stacks that meet the given filter.

func MapToResourceTags

func MapToResourceTags(tagMap map[string]string) []interface{}

MapToResourceTags transforms a go map[string]string to a CloudFormation-compliant Tags representation. See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html

func S3AllKeysArnForBucket

func S3AllKeysArnForBucket(bucket interface{}) *gocf.StringExpr

S3AllKeysArnForBucket returns a CloudFormation-compatible Arn expression (string or Ref) for all bucket keys (`/*`). The bucket parameter may be either a string or an interface{} ("Ref: "myResource") value

func S3ArnForBucket

func S3ArnForBucket(bucket interface{}) *gocf.StringExpr

S3ArnForBucket returns a CloudFormation-compatible Arn expression (string or Ref) suitable for template reference. The bucket parameter may be either a string or an interface{} ("Ref: "myResource") value

func StackEvents added in v1.3.0

func StackEvents(stackID string,
	eventFilterLowerBoundInclusive time.Time,
	awsSession *session.Session) ([]*cloudformation.StackEvent, error)

StackEvents returns the slice of cloudformation.StackEvents for the given stackID or stackName

func StackExists added in v1.3.0

func StackExists(stackNameOrID string, awsSession *session.Session, logger *logrus.Logger) (bool, error)

StackExists returns whether the given stackName or stackID currently exists

func UploadTemplate added in v1.3.0

func UploadTemplate(serviceName string,
	cfTemplate *gocf.Template,
	s3Bucket string,
	s3KeyName string,
	awsSession *session.Session,
	logger *logrus.Logger) (string, error)

UploadTemplate marshals the given cfTemplate and uploads it to the supplied bucket using the given KeyName

func UserAccountScopedStackName added in v1.3.0

func UserAccountScopedStackName(basename string,
	awsSession *session.Session) (string, error)

UserAccountScopedStackName returns a CloudFormation stack name that takes into account the current username that is associated with the supplied AWS credentials

A stack name can contain only alphanumeric characters (case sensitive) and hyphens. It must start with an alphabetic \character and cannot be longer than 128 characters.

func UserScopedStackName added in v1.3.0

func UserScopedStackName(basename string) string

UserScopedStackName returns a CloudFormation stack name that takes into account the current username

A stack name can contain only alphanumeric characters (case sensitive) and hyphens. It must start with an alphabetic \character and cannot be longer than 128 characters.

Types

type AutoIncrementingLambdaVersionInfo added in v1.3.0

type AutoIncrementingLambdaVersionInfo struct {
	// The version that will be published as part of this operation
	CurrentVersion int
	// The CloudFormation resource name that defines the
	// AWS::Lambda::Version resource to be included with this operation
	CurrentVersionResourceName string
	// The version history that maps a published version value
	// to its CloudFormation resource name. Used for defining lagging
	// indicator Alias values
	VersionHistory map[int]string
}

AutoIncrementingLambdaVersionInfo is dynamically populated during a call AddAutoIncrementingLambdaVersionResource. The VersionHistory is a map of published versions to their CloudFormation resource names

func AddAutoIncrementingLambdaVersionResource added in v1.3.0

func AddAutoIncrementingLambdaVersionResource(serviceName string,
	lambdaResourceName string,
	cfTemplate *gocf.Template,
	logger *logrus.Logger) (*AutoIncrementingLambdaVersionInfo, error)

AddAutoIncrementingLambdaVersionResource inserts a new AWS::Lambda::Version resource into the template. It uses the existing CloudFormation template representation to determine the version index to append. The returned map is from `versionIndex`->`CloudFormationResourceName` to support second-order AWS::Lambda::Alias records on a per-version level

type WaitForStackOperationCompleteResult added in v1.3.0

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

WaitForStackOperationCompleteResult encapsulates the stackInfo following a WaitForStackOperationComplete call

func WaitForStackOperationComplete added in v1.3.0

func WaitForStackOperationComplete(stackID string,
	pollingMessage string,
	awsCloudFormation *cloudformation.CloudFormation,
	logger *logrus.Logger) (*WaitForStackOperationCompleteResult, error)

WaitForStackOperationComplete is a blocking, polling based call that periodically fetches the stackID set of events and uses the state value to determine if an operation is complete

Directories

Path Synopsis
Package main provides a simple cli tool to produce a DescribeStackResponse for a given CloudFormation Stack Name or ID.
Package main provides a simple cli tool to produce a DescribeStackResponse for a given CloudFormation Stack Name or ID.
Package resources defines a set of CloudFormation Custom Resources that are implemented by Lambda functions.
Package resources defines a set of CloudFormation Custom Resources that are implemented by Lambda functions.

Jump to

Keyboard shortcuts

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