-
Notifications
You must be signed in to change notification settings - Fork 8
/
cloudformation.go
110 lines (92 loc) · 5.17 KB
/
cloudformation.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2018 Appliscale
//
// Maintainers and contributors are listed in README file inside repository.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package awsapi contains interface with all functions which use AWS CloudFormation API.
package awsapi
import (
"github.com/aws/aws-sdk-go/service/cloudformation"
)
// CloudFormationAPI collects all functions which using Cloudformation, e.g creating stack.
type CloudFormationAPI interface {
CreateStack(input *cloudformation.CreateStackInput) (*cloudformation.CreateStackOutput, error)
DeleteStack(input *cloudformation.DeleteStackInput) (*cloudformation.DeleteStackOutput, error)
UpdateStack(input *cloudformation.UpdateStackInput) (*cloudformation.UpdateStackOutput, error)
SetStackPolicy(input *cloudformation.SetStackPolicyInput) (*cloudformation.SetStackPolicyOutput, error)
UpdateTerminationProtection(input *cloudformation.UpdateTerminationProtectionInput) (*cloudformation.UpdateTerminationProtectionOutput, error)
EstimateTemplateCost(input *cloudformation.EstimateTemplateCostInput) (*cloudformation.EstimateTemplateCostOutput, error)
ValidateTemplate(input *cloudformation.ValidateTemplateInput) (*cloudformation.ValidateTemplateOutput, error)
CreateChangeSet(input *cloudformation.CreateChangeSetInput) (*cloudformation.CreateChangeSetOutput, error)
DescribeChangeSet(input *cloudformation.DescribeChangeSetInput) (*cloudformation.DescribeChangeSetOutput, error)
WaitUntilChangeSetCreateComplete(input *cloudformation.DescribeChangeSetInput) error
DeleteChangeSet(input *cloudformation.DeleteChangeSetInput) (*cloudformation.DeleteChangeSetOutput, error)
}
// AWSCloudFormationAPI implements CLoudFormationAPI.
type AWSCloudFormationAPI struct {
api *cloudformation.CloudFormation
}
// NewAWSCloudFormation creates CloudFormationAPI.
func NewAWSCloudFormation(api *cloudformation.CloudFormation) CloudFormationAPI {
awsCloudFormationAPI := AWSCloudFormationAPI{
api: api,
}
return &awsCloudFormationAPI
}
// CreateStack creates stack based on user template.
func (cf *AWSCloudFormationAPI) CreateStack(input *cloudformation.CreateStackInput) (*cloudformation.CreateStackOutput, error) {
return cf.api.CreateStack(input)
}
// DeleteStack destroys template based on stack name.
func (cf *AWSCloudFormationAPI) DeleteStack(input *cloudformation.DeleteStackInput) (*cloudformation.DeleteStackOutput, error) {
return cf.api.DeleteStack(input)
}
// UpdateStack updates stack template.
func (cf *AWSCloudFormationAPI) UpdateStack(input *cloudformation.UpdateStackInput) (*cloudformation.UpdateStackOutput, error) {
return cf.api.UpdateStack(input)
}
// SetStackPolicy sets policy based on template or flag.
func (cf *AWSCloudFormationAPI) SetStackPolicy(input *cloudformation.SetStackPolicyInput) (*cloudformation.SetStackPolicyOutput, error) {
return cf.api.SetStackPolicy(input)
}
// UpdateTerminationProtection allows to change stack protection from termination.
func (cf *AWSCloudFormationAPI) UpdateTerminationProtection(input *cloudformation.UpdateTerminationProtectionInput) (*cloudformation.UpdateTerminationProtectionOutput, error) {
return cf.api.UpdateTerminationProtection(input)
}
// EstimateTemplateCost shows stack cost.
func (cf *AWSCloudFormationAPI) EstimateTemplateCost(input *cloudformation.EstimateTemplateCostInput) (*cloudformation.EstimateTemplateCostOutput, error) {
return cf.api.EstimateTemplateCost(input)
}
// ValidateTemplate checks template correctness.
func (cf *AWSCloudFormationAPI) ValidateTemplate(input *cloudformation.ValidateTemplateInput) (*cloudformation.ValidateTemplateOutput, error) {
return cf.api.ValidateTemplate(input)
}
// CreateChangeSet creates ChangeSet.
func (cf *AWSCloudFormationAPI) CreateChangeSet(input *cloudformation.CreateChangeSetInput) (*cloudformation.CreateChangeSetOutput, error) {
return cf.api.CreateChangeSet(input)
}
// DescribeChangeSet returns the inputs and a list of changes.
func (cf *AWSCloudFormationAPI) DescribeChangeSet(input *cloudformation.DescribeChangeSetInput) (*cloudformation.DescribeChangeSetOutput, error) {
return cf.api.DescribeChangeSet(input)
}
// WaitUntilChangeSetCreateComplete uses the AWS CloudFormation API operation
// DescribeChangeSet to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (cf *AWSCloudFormationAPI) WaitUntilChangeSetCreateComplete(input *cloudformation.DescribeChangeSetInput) error {
return cf.api.WaitUntilChangeSetCreateComplete(input)
}
// DeleteChangeSet removes ChangeSet.
func (cf *AWSCloudFormationAPI) DeleteChangeSet(input *cloudformation.DeleteChangeSetInput) (*cloudformation.DeleteChangeSetOutput, error) {
return cf.api.DeleteChangeSet(input)
}