Skip to content

Commit 2c219ec

Browse files
committed
Adds resource tagging
Introduces optional tags fields to unify resource metadata Enables consistent tagging for improved environment management
1 parent b5f444a commit 2c219ec

File tree

14 files changed

+139
-20
lines changed

14 files changed

+139
-20
lines changed

pkg/manifest/resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type Resource struct {
44
Name string `yaml:"-"`
55
Type string `yaml:"type"`
66
Options map[string]string `yaml:"options"`
7+
Tags map[string]string `yaml:"tags"`
78
}
89

910
type Resources []Resource

pkg/manifest/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Service struct {
2929
Scale ServiceScale `yaml:"scale,omitempty"`
3030
Singleton bool `yaml:"singleton,omitempty"`
3131
Sticky bool `yaml:"sticky,omitempty"`
32+
Tags map[string]string `yaml:"tags,omitempty"`
3233
Termination ServiceTermination `yaml:"termination,omitempty"`
3334
Test string `yaml:"test,omitempty"`
3435
Volumes []string `yaml:"volumes,omitempty"`

provider/aws/formation/resource/efs.json.tmpl

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@
8181
"Path": {
8282
"Ref": "Path"
8383
}
84-
}
84+
},
85+
"AccessPointTags": [
86+
{{ range $key, $value := .Tags }}
87+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
88+
{{ end }}
89+
{ "Key": "Name", "Value": "{{.Name}}" }
90+
]
8591
}
8692
},
8793
"EncryptionKey": {
@@ -109,7 +115,13 @@
109115
}
110116
]
111117
},
112-
"PendingWindowInDays": "7"
118+
"PendingWindowInDays": "7",
119+
"Tags": [
120+
{{ range $key, $value := .Tags }}
121+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
122+
{{ end }}
123+
{ "Key": "Name", "Value": "{{.Name}}" }
124+
]
113125
}
114126
},
115127
"FileSystem": {
@@ -136,7 +148,13 @@
136148
"Ref": "AWS::NoValue"
137149
}
138150
]
139-
}
151+
},
152+
"FileSystemTags": [
153+
{{ range $key, $value := .Tags }}
154+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
155+
{{ end }}
156+
{ "Key": "Name", "Value": "{{.Name}}" }
157+
]
140158
}
141159
},
142160
"MountTargetSecurityGroup": {
@@ -161,6 +179,12 @@
161179
}
162180
}
163181
}
182+
],
183+
"Tags": [
184+
{{ range $key, $value := .Tags }}
185+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
186+
{{ end }}
187+
{ "Key": "Name", "Value": "{{.Name}}" }
164188
]
165189
}
166190
},

provider/aws/formation/resource/mariadb.json.tmpl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"Class": {
2626
"Type": "String",
27-
"Default": "db.t2.micro"
27+
"Default": "db.t3.micro"
2828
},
2929
"DeletionProtection": {
3030
"Type": "String",
@@ -99,7 +99,13 @@
9999
"SecurityGroupIngress": [
100100
{ "IpProtocol": "tcp", "FromPort": "3306", "ToPort": "3306", "CidrIp": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:VpcCidr" } } }
101101
],
102-
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } }
102+
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } },
103+
"Tags": [
104+
{{ range $key, $value := .Tags }}
105+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
106+
{{ end }}
107+
{ "Key": "Name", "Value": "{{.Name}}" }
108+
]
103109
}
104110
},
105111
"SubnetGroup": {
@@ -109,6 +115,12 @@
109115
"SubnetIds": [
110116
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet0" } },
111117
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet1" } }
118+
],
119+
"Tags": [
120+
{{ range $key, $value := .Tags }}
121+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
122+
{{ end }}
123+
{ "Key": "Name", "Value": "{{.Name}}" }
112124
]
113125
}
114126
},
@@ -145,7 +157,13 @@
145157
"StorageEncrypted": { "Fn::If": [ "NotBlankSnapshot", { "Ref": "AWS::NoValue" }, { "Ref": "Encrypted" } ] },
146158
"StorageType": { "Fn::If": [ "BlankIops", "gp2", "io2" ] },
147159
"SourceDBInstanceIdentifier": { "Fn::If": [ "IsReadReplica", { "Ref": "ReadSourceDB" }, { "Ref": "AWS::NoValue" } ] },
148-
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ]
160+
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ],
161+
"Tags": [
162+
{{ range $key, $value := .Tags }}
163+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
164+
{{ end }}
165+
{ "Key": "Name", "Value": "{{.Name}}" }
166+
]
149167
}
150168
}
151169
}

provider/aws/formation/resource/memcached.json.tmpl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"SecurityGroupIngress": [
4949
{ "IpProtocol": "tcp", "FromPort": "11211", "ToPort": "11211", "CidrIp": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:VpcCidr" } } }
5050
],
51-
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } }
51+
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } },
52+
"Tags": [
53+
{{ range $key, $value := .Tags }}
54+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
55+
{{ end }}
56+
{ "Key": "Name", "Value": "{{.Name}}" }
57+
]
5258
}
5359
},
5460
"SubnetGroup": {
@@ -58,6 +64,12 @@
5864
"SubnetIds": [
5965
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet0" } },
6066
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet1" } }
67+
],
68+
"Tags": [
69+
{{ range $key, $value := .Tags }}
70+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
71+
{{ end }}
72+
{ "Key": "Name", "Value": "{{.Name}}" }
6173
]
6274
}
6375
},
@@ -71,7 +83,13 @@
7183
"EngineVersion": { "Ref": "Version" },
7284
"NumCacheNodes": { "Ref": "Nodes" },
7385
"Port": "11211",
74-
"VpcSecurityGroupIds": [ { "Ref": "SecurityGroup" } ]
86+
"VpcSecurityGroupIds": [ { "Ref": "SecurityGroup" } ],
87+
"Tags": [
88+
{{ range $key, $value := .Tags }}
89+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
90+
{{ end }}
91+
{ "Key": "Name", "Value": "{{.Name}}" }
92+
]
7593
}
7694
}
7795
}

provider/aws/formation/resource/mysql.json.tmpl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"Class": {
2626
"Type": "String",
27-
"Default": "db.t2.micro"
27+
"Default": "db.t3.micro"
2828
},
2929
"DeletionProtection": {
3030
"Type": "String",
@@ -99,7 +99,13 @@
9999
"SecurityGroupIngress": [
100100
{ "IpProtocol": "tcp", "FromPort": "3306", "ToPort": "3306", "CidrIp": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:VpcCidr" } } }
101101
],
102-
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } }
102+
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } },
103+
"Tags": [
104+
{{ range $key, $value := .Tags }}
105+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
106+
{{ end }}
107+
{ "Key": "Name", "Value": "{{.Name}}" }
108+
]
103109
}
104110
},
105111
"SubnetGroup": {
@@ -109,6 +115,12 @@
109115
"SubnetIds": [
110116
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet0" } },
111117
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet1" } }
118+
],
119+
"Tags": [
120+
{{ range $key, $value := .Tags }}
121+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
122+
{{ end }}
123+
{ "Key": "Name", "Value": "{{.Name}}" }
112124
]
113125
}
114126
},
@@ -145,7 +157,13 @@
145157
"StorageEncrypted": { "Fn::If": [ "NotBlankSnapshot", { "Ref": "AWS::NoValue" }, { "Ref": "Encrypted" } ] },
146158
"StorageType": { "Fn::If": [ "BlankIops", "gp2", "io2" ] },
147159
"SourceDBInstanceIdentifier": { "Fn::If": [ "IsReadReplica", { "Ref": "ReadSourceDB" }, { "Ref": "AWS::NoValue" } ] },
148-
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ]
160+
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ],
161+
"Tags": [
162+
{{ range $key, $value := .Tags }}
163+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
164+
{{ end }}
165+
{ "Key": "Name", "Value": "{{.Name}}" }
166+
]
149167
}
150168
}
151169
}

provider/aws/formation/resource/postgres.json.tmpl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"Class": {
2727
"Type": "String",
28-
"Default": "db.t2.micro"
28+
"Default": "db.t3.micro"
2929
},
3030
"DeletionProtection": {
3131
"Type": "String",
@@ -100,6 +100,12 @@
100100
"SecurityGroupIngress": [
101101
{ "IpProtocol": "tcp", "FromPort": "5432", "ToPort": "5432", "CidrIp": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:VpcCidr" } } }
102102
],
103+
"Tags": [
104+
{{ range $key, $value := .Tags }}
105+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
106+
{{ end }}
107+
{ "Key": "Name", "Value": "{{.Name}}" }
108+
],
103109
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } }
104110
}
105111
},
@@ -110,6 +116,12 @@
110116
"SubnetIds": [
111117
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet0" } },
112118
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet1" } }
119+
],
120+
"Tags": [
121+
{{ range $key, $value := .Tags }}
122+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
123+
{{ end }}
124+
{ "Key": "Name", "Value": "{{.Name}}" }
113125
]
114126
}
115127
},
@@ -151,6 +163,12 @@
151163
"StorageEncrypted": { "Fn::If": [ "NotBlankSnapshot", { "Ref": "AWS::NoValue" }, { "Ref": "Encrypted" } ] },
152164
"StorageType": { "Fn::If": [ "BlankIops", "gp2", "io2" ] },
153165
"SourceDBInstanceIdentifier": { "Fn::If": [ "IsReadReplica", { "Ref": "ReadSourceDB" }, { "Ref": "AWS::NoValue" } ] },
166+
"Tags": [
167+
{{ range $key, $value := .Tags }}
168+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
169+
{{ end }}
170+
{ "Key": "Name", "Value": "{{.Name}}" }
171+
],
154172
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ]
155173
}
156174
}

provider/aws/formation/resource/redis.json.tmpl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"Version": {
4040
"Type": "String",
41-
"Default": "3.2.6"
41+
"Default": "7.0",
4242
}
4343
},
4444
"Outputs": {
@@ -71,7 +71,13 @@
7171
"SecurityGroupIngress": [
7272
{ "IpProtocol": "tcp", "FromPort": "6379", "ToPort": "6379", "CidrIp": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:VpcCidr" } } }
7373
],
74-
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } }
74+
"VpcId": { "Fn::ImportValue": { "Fn::Sub": "${Rack}:Vpc" } },
75+
"Tags": [
76+
{{ range $key, $value := .Tags }}
77+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
78+
{{ end }}
79+
{ "Key": "Name", "Value": "{{.Name}}" }
80+
]
7581
}
7682
},
7783
"SubnetGroup": {
@@ -81,6 +87,12 @@
8187
"SubnetIds": [
8288
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet0" } },
8389
{ "Fn::ImportValue": { "Fn::Sub": "${Rack}:Subnet1" } }
90+
],
91+
"Tags": [
92+
{{ range $key, $value := .Tags }}
93+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
94+
{{ end }}
95+
{ "Key": "Name", "Value": "{{.Name}}" }
8496
]
8597
}
8698
},
@@ -105,7 +117,13 @@
105117
"Port": "6379",
106118
"ReplicationGroupDescription": { "Ref": "AWS::StackName" },
107119
"SecurityGroupIds": [ { "Ref": "SecurityGroup" } ],
108-
"TransitEncryptionEnabled": { "Ref": "Encrypted" }
120+
"TransitEncryptionEnabled": { "Ref": "Encrypted" },
121+
"Tags": [
122+
{{ range $key, $value := .Tags }}
123+
{ "Key": "{{ $key }}", "Value": "{{ $value }}" },
124+
{{ end }}
125+
{ "Key": "Name", "Value": "{{.Name}}" }
126+
]
109127
}
110128
}
111129
}

provider/aws/releases.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ func (p *Provider) ReleasePromote(app, id string, opts structs.ReleasePromoteOpt
270270
}
271271

272272
rtp := map[string]interface{}{
273+
"Name": r.Name,
273274
"ThirdAvailabilityZone": hasThirdAZ,
275+
"Tags": r.Tags,
274276
}
275277

276278
var data []byte
@@ -371,6 +373,7 @@ func (p *Provider) ReleasePromote(app, id string, opts structs.ReleasePromoteOpt
371373
"Password": p.Password,
372374
"Release": tp["Release"],
373375
"Service": s,
376+
"Tags": s.Tags,
374377
"WildcardDomain": tp["WildcardDomain"],
375378
}
376379

provider/aws/templates/resource/mysql.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"InstanceType": {
3131
"Type" : "String",
32-
"Default" : "db.t2.micro",
32+
"Default" : "db.t3.micro",
3333
"Description" : "Instance class for database nodes"
3434
},
3535
"MultiAZ": {

0 commit comments

Comments
 (0)