-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate.go
75 lines (66 loc) · 2.86 KB
/
template.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
// Package template provides types and functions that enable programmatic generation of CloudFormation templates
package template
import "encoding/json"
// Template defines a CloudFormation template.
//
// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html
type Template struct {
AWSTemplateFormatVersion string `json:",omitempty"`
Description string `json:",omitempty"`
Metadata map[string]interface{} `json:",omitempty"`
Parameters map[string]Parameter `json:",omitempty"`
Mappings map[string]Mapping `json:",omitempty"`
Conditions map[string]Condition `json:",omitempty"`
Resources map[string]Resource `json:",omitempty"`
Outputs map[string]Output `json:",omitempty"`
}
// Parameter defines a CloudFormation template parameter
//
// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
type Parameter struct {
Type string
Default string `json:",omitempty"`
NoEcho bool `json:",omitempty,string"`
AllowedValues []string `json:",omitempty"`
AllowedPattern string `json:",omitempty"`
MaxLength int `json:",omitempty,string"`
MinLength int `json:",omitempty,string"`
Description string `json:",omitempty"`
ConstraintDescription string `json:",omitempty"`
}
// Mapping defines a CloudFormation template mapping
//
// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html
type Mapping map[string]map[string]string
// Condition defines a CloudFormation template condition
//
// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html
type Condition map[string]interface{}
// Resource defines a CloudFormation template resource
//
// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
type Resource struct {
Type string
Properties map[string]interface{} `json:",omitempty"`
Metadata map[string]interface{} `json:",omitempty"`
DependsOn interface{} `json:",omitempty"`
CreationPolicy interface{} `json:",omitempty"`
UpdatePolicy interface{} `json:",omitempty"`
DeletionPolicy interface{} `json:",omitempty"`
}
// Output defines a CloudFormation template output
//
// http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html
type Output struct {
Description string `json:",omitempty"`
Value interface{}
}
// String returns a JSON representation of the Template suitable for use
// in CloudFormation requests such as CreateStack and UpdateStack
func (t *Template) String() string {
bytes, err := json.Marshal(t)
if err != nil {
panic(err)
}
return string(bytes)
}