Skip to content

Commit

Permalink
AWS machine module - add a count attribute to 'additional_volumes' to…
Browse files Browse the repository at this point in the history
… easily create multiple volumes to be used with the same 'volume_group'
  • Loading branch information
bryan-bar committed Nov 17, 2023
1 parent dfbbf19 commit 130e77a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ locals {
# assign zone from mapped names
zone = var.spec.regions[machine_spec.region].zones[machine_spec.zone_name].zone
cidr = var.spec.regions[machine_spec.region].zones[machine_spec.zone_name].cidr

# expand any additional volumes with count > 1 and then merge the lists as a single list
additional_volumes = length(machine_spec.additional_volumes) > 0 ? flatten([
for volume in machine_spec.additional_volumes: [
for index in range(volume.count): volume
]
]) : machine_spec.additional_volumes
})
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ variable "spec" {
# Use jbod_volumes which are meant to represent "Just a bunch of Disks(Volumes)" as an alternative
# to manually manage per machine instance post-terraform
additional_volumes = optional(list(object({
count = optional(number, 1)
mount_point = optional(string)
size_gb = number
iops = optional(number)
Expand Down
12 changes: 4 additions & 8 deletions infrastructure-examples/aws/machines-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aws:
zone: us-west-2b
cidr: 10.2.20.0/24
main:
zone: us-west-2b
zone: us-west-2a
cidr: 10.2.30.0/24
service_ports:
- port: 22
Expand Down Expand Up @@ -48,6 +48,7 @@ aws:
tags:
type: dbt2-driver
pg1:
count: 2
image_name: rocky
region: us-west-2
zone_name: main
Expand All @@ -72,7 +73,8 @@ aws:
size_gb: 100
encrypted: false
additional_volumes:
- size_gb: 20
- count: 4
size_gb: 20
type: gp3
iops: 4000
throughput: 1000
Expand All @@ -89,12 +91,6 @@ aws:
iops: 5000
encrypted: false
filesystem: xfs
- size_gb: 20
type: gp3
iops: 4000
throughput: 1000
encrypted: false
volume_group: data
volume_groups:
data:
/opt/data0:
Expand Down

0 comments on commit 130e77a

Please sign in to comment.