Sparta: Index | Examples | Files | Directories

package cloudformation

import ""

Package cloudformation scopes CloudFormation-specific utiltities for Sparta



Package Files

doc.go impl_build.go impl_linux.go util.go

func CloudFormationResourceName Uses

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

CloudFormationResourceName returns a name suitable as a logical CloudFormation resource value. See 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 Uses

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 Uses

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.


package main

import (

var sampleTemplate = `
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)

func CreateStackChangeSet Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

MapToResourceTags transforms a go map[string]string to a CloudFormation-compliant Tags representation. See

func S3AllKeysArnForBucket Uses

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 Uses

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 Uses

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 Uses

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

StackExists returns whether the given stackName or stackID currently exists

func UploadTemplate Uses

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 Uses

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 Uses

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.

type AutoIncrementingLambdaVersionInfo Uses

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 Uses

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 Uses

type WaitForStackOperationCompleteResult struct {
    // contains filtered or unexported fields

WaitForStackOperationCompleteResult encapsulates the stackInfo following a WaitForStackOperationComplete call

func WaitForStackOperationComplete Uses

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


resourcesPackage resources defines a set of CloudFormation Custom Resources that are implemented by Lambda functions.

Package cloudformation imports 27 packages (graph) and is imported by 9 packages. Updated 2018-10-22. Refresh now. Tools for package owners.