cloudformation

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: MIT Imports: 25 Imported by: 48

Documentation

Overview

Package cloudformation scopes CloudFormation-specific utiltities for Sparta

Index

Examples

Constants

View Source
const (
	// Endpoint property
	Endpoint = "endpoint"
	// Protocol property
	Protocol = "protocol"
	// HostedZoneID property
	HostedZoneID = "hostedZoneID"
)

Variables

View Source
var APIGatewayMapping = &gocf.Mapping{
	"us-east-2": map[string]string{
		Endpoint:     "apigateway.us-east-2.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "ZOJJZC49E0EPZ",
	},
	"us-east-1": map[string]string{
		Endpoint:     "apigateway.us-east-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z1UJRXOUMOOFQ8",
	},
	"us-west-1": map[string]string{
		Endpoint:     "apigateway.us-west-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z2MUQ32089INYE",
	},
	"us-west-2": map[string]string{
		Endpoint:     "apigateway.us-west-2.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z2OJLYMUO9EFXC",
	},
	"ap-south-1": map[string]string{
		Endpoint:     "apigateway.ap-south-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z3VO1THU9YC4UR",
	},
	"ap-northeast-3": map[string]string{
		Endpoint:     "apigateway.ap-northeast-3.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z2YQB5RD63NC85",
	},
	"ap-northeast-2": map[string]string{
		Endpoint:     "apigateway.ap-northeast-2.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z20JF4UZKIW1U8",
	},
	"ap-southeast-1": map[string]string{
		Endpoint:     "apigateway.ap-southeast-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "ZL327KTPIQFUL",
	},
	"ap-southeast-2": map[string]string{
		Endpoint:     "apigateway.ap-southeast-2.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z2RPCDW04V8134",
	},
	"ap-northeast-1": map[string]string{
		Endpoint:     "apigateway.ap-northeast-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z1YSHQZHG15GKL",
	},
	"ca-central-1": map[string]string{
		Endpoint:     "apigateway.ca-central-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z19DQILCV0OWEC",
	},
	"cn-north-1": map[string]string{
		Endpoint:     "apigateway.cn-north-1.amazonaws.com.cn",
		Protocol:     "HTTPS",
		HostedZoneID: "",
	},
	"cn-northwest-1": map[string]string{
		Endpoint:     "apigateway.cn-northwest-1.amazonaws.com.cn",
		Protocol:     "HTTPS",
		HostedZoneID: "",
	},
	"eu-central-1": map[string]string{
		Endpoint:     "apigateway.eu-central-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z1U9ULNL0V5AJ3",
	},
	"eu-west-1": map[string]string{
		Endpoint:     "apigateway.eu-west-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "ZLY8HYME6SFDD",
	},
	"eu-west-2": map[string]string{
		Endpoint:     "apigateway.eu-west-2.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "ZJ5UAJN8Y3Z2Q",
	},
	"eu-west-3": map[string]string{
		Endpoint:     "apigateway.eu-west-3.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z3KY65QIEKYHQQ",
	},
	"eu-north-1": map[string]string{
		Endpoint:     "apigateway.eu-north-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "Z2YB950C88HT6D",
	},
	"sa-east-1": map[string]string{
		Endpoint:     "apigateway.sa-east-1.amazonaws.com",
		Protocol:     "HTTPS",
		HostedZoneID: "ZCMLWB8V5SYIT",
	},
}

APIGatewayMapping is the mapping for APIGateway settings

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 ConvertToInlineJSONTemplateExpression added in v1.8.0

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

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

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 StableResourceName added in v1.12.0

func StableResourceName(value string) string

StableResourceName returns a stable resource name

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 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