Documentation ¶
Overview ¶
Package cloudformation scopes CloudFormation-specific utiltities for Sparta
Index ¶
- Constants
- Variables
- func CloudFormationResourceName(prefix string, parts ...string) string
- func ConvergeStackState(serviceName string, cfTemplate *gocf.Template, templateURL string, ...) (*cloudformation.Stack, error)
- func ConvertToInlineJSONTemplateExpression(templateData io.Reader, ...) (*gocf.StringExpr, error)
- func ConvertToTemplateExpression(templateData io.Reader, ...) (*gocf.StringExpr, error)
- func CreateStackChangeSet(changeSetRequestName string, serviceName string, cfTemplate *gocf.Template, ...) (*cloudformation.DescribeChangeSetOutput, error)
- func DeleteChangeSet(stackName string, changeSetRequestName string, ...) (*cloudformation.DeleteChangeSetOutput, error)
- func DynamicValueToStringExpr(dynamicValue interface{}) gocf.Stringable
- func ListStacks(session *session.Session, maxReturned int, stackFilters ...string) ([]*cloudformation.StackSummary, error)
- func MapToResourceTags(tagMap map[string]string) []interface{}
- func S3AllKeysArnForBucket(bucket interface{}) *gocf.StringExpr
- func S3ArnForBucket(bucket interface{}) *gocf.StringExpr
- func StackEvents(stackID string, eventFilterLowerBoundInclusive time.Time, ...) ([]*cloudformation.StackEvent, error)
- func StackExists(stackNameOrID string, awsSession *session.Session, logger *logrus.Logger) (bool, error)
- func UploadTemplate(serviceName string, cfTemplate *gocf.Template, s3Bucket string, ...) (string, error)
- func UserAccountScopedStackName(basename string, awsSession *session.Session) (string, error)
- func UserScopedStackName(basename string) string
- type WaitForStackOperationCompleteResult
Examples ¶
Constants ¶
const ( // Endpoint property Endpoint = "endpoint" // Protocol property Protocol = "protocol" // HostedZoneID property HostedZoneID = "hostedZoneID" )
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func StackExists(stackNameOrID string, awsSession *session.Session, logger *logrus.Logger) (bool, error)
StackExists returns whether the given stackName or stackID currently exists
func UploadTemplate ¶
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 ¶
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 ¶
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 ¶
type WaitForStackOperationCompleteResult struct {
// contains filtered or unexported fields
}
WaitForStackOperationCompleteResult encapsulates the stackInfo following a WaitForStackOperationComplete call
func WaitForStackOperationComplete ¶
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. |