File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ terraform {
10
10
variable "instances" {
11
11
type = map (object ({
12
12
instance_type = string
13
+ instance_arch = string
13
14
storage = number
14
15
}))
15
16
}
Original file line number Diff line number Diff line change 3
3
resource "aws_instance" "instance" {
4
4
for_each = var. instances
5
5
6
- ami = data. aws_ami . instance . id
6
+ ami = data. aws_ami . instance [ each . value . instance_arch ] . id
7
7
instance_type = each. value . instance_type
8
8
key_name = aws_key_pair. instance . key_name
9
9
ebs_optimized = true
@@ -32,12 +32,14 @@ resource "aws_instance" "instance" {
32
32
}
33
33
34
34
data "aws_ami" "instance" {
35
+ for_each = toset (values (var. instances )[* ]. instance_arch )
36
+
35
37
most_recent = true
36
38
owners = [" 099720109477" ] # Canonical
37
39
38
40
filter {
39
41
name = " name"
40
- values = [" ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-arm64 -server-*" ]
42
+ values = [" ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-${ each . key } -server-*" ]
41
43
}
42
44
43
45
filter {
Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ module "aws_eu_central_1" {
7
7
instances = {
8
8
" dev-desktop-staging" = {
9
9
instance_type = " t3a.micro"
10
+ instance_arch = " amd64"
10
11
storage = 25
11
12
}
12
13
" dev-desktop-eu-1" = {
13
14
instance_type = " c6g.8xlarge"
15
+ instance_arch = " arm64"
14
16
storage = 1000
15
17
}
16
18
}
@@ -25,6 +27,7 @@ module "aws_us_east_1" {
25
27
instances = {
26
28
" dev-desktop-us-1" = {
27
29
instance_type = " c7g.8xlarge"
30
+ instance_arch = " arm64"
28
31
storage = 1000
29
32
}
30
33
}
You can’t perform that action at this time.
0 commit comments