Skip to content

Commit 3c5f083

Browse files
authored
Merge pull request #94 from jeroenhabets/ebs-volume-tags-79
Name and tag cluster worker EBS volumes
2 parents 851214c + 61c1574 commit 3c5f083

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ IMPROVEMENTS:
1414
users of this module to require that IMDSv2 be used by containers in the
1515
cluster. By default, IMDSv2 is not required in this version of the module but
1616
a future major release of the module may enforce IMDSv2 usage.
17-
17+
* The EBS volumes attached to container instances are now tagged with
18+
`Component`, `DeploymentIdentifier`, `Name` and `ClusterName` tags by default,
19+
as well as with any tags passed in the `tags` var when provided (resolves
20+
#94).
1821

1922
## 6.0.0 (February 22th 2023)
2023

asg.tf

+11
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ resource "aws_launch_template" "cluster" {
6262
enabled = var.enable_detailed_monitoring
6363
}
6464

65+
tag_specifications {
66+
resource_type = "volume"
67+
tags = merge(
68+
local.tags,
69+
{
70+
Name = "cluster-worker-${var.component}-${var.deployment_identifier}-${var.cluster_name}"
71+
ClusterName = var.cluster_name
72+
}
73+
)
74+
}
75+
6576
depends_on = [
6677
null_resource.iam_wait
6778
]

spec/unit/launch_template_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
let(:dep_id) do
1010
var(role: :root, name: 'deployment_identifier')
1111
end
12+
let(:cluster_name) do
13+
'default'
14+
end
15+
let(:tags) do
16+
var(role: :root, name: 'tags')
17+
end
1218
let(:region) do
1319
var(role: :root, name: 'region')
1420
end
@@ -161,6 +167,26 @@
161167
end
162168
end
163169

170+
describe 'tag specifications' do
171+
it 'sets default and provided tags on volumes' do
172+
expect(@plan)
173+
.to(include_resource_creation(type: 'aws_launch_template')
174+
.with_attribute_value(
175+
[:tag_specifications, 0],
176+
{
177+
resource_type: 'volume',
178+
tags: {
179+
'Component' => component,
180+
'DeploymentIdentifier' => dep_id,
181+
'Name' =>
182+
"cluster-worker-#{component}-#{dep_id}-#{cluster_name}",
183+
'ClusterName' => cluster_name
184+
}.merge(tags)
185+
}
186+
))
187+
end
188+
end
189+
164190
context 'when root block device path is specified' do
165191
device_path = '/custom/path'
166192

0 commit comments

Comments
 (0)