This repository has been archived by the owner on Sep 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 295
/
cfnstack.go
52 lines (43 loc) · 1.78 KB
/
cfnstack.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cfnstack
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/aws/aws-sdk-go/service/s3"
"strings"
)
var CFN_TEMPLATE_SIZE_LIMIT = 51200
type CreationService interface {
CreateStack(*cloudformation.CreateStackInput) (*cloudformation.CreateStackOutput, error)
}
type UpdateService interface {
UpdateStack(input *cloudformation.UpdateStackInput) (*cloudformation.UpdateStackOutput, error)
}
type CRUDService interface {
CreateStack(*cloudformation.CreateStackInput) (*cloudformation.CreateStackOutput, error)
UpdateStack(input *cloudformation.UpdateStackInput) (*cloudformation.UpdateStackOutput, error)
DescribeStacks(input *cloudformation.DescribeStacksInput) (*cloudformation.DescribeStacksOutput, error)
DescribeStackEvents(input *cloudformation.DescribeStackEventsInput) (*cloudformation.DescribeStackEventsOutput, error)
EstimateTemplateCost(input *cloudformation.EstimateTemplateCostInput) (*cloudformation.EstimateTemplateCostOutput, error)
}
type S3ObjectPutterService interface {
PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error)
}
func StackEventErrMsgs(events []*cloudformation.StackEvent) []string {
var errMsgs []string
for _, event := range events {
if aws.StringValue(event.ResourceStatus) == cloudformation.ResourceStatusCreateFailed {
// Only show actual failures, not cancelled dependent resources.
if aws.StringValue(event.ResourceStatusReason) != "Resource creation cancelled" {
errMsgs = append(errMsgs,
strings.TrimSpace(
strings.Join([]string{
aws.StringValue(event.ResourceStatus),
aws.StringValue(event.ResourceType),
aws.StringValue(event.LogicalResourceId),
aws.StringValue(event.ResourceStatusReason),
}, " ")))
}
}
}
return errMsgs
}