Skip to content

Commit 9ef24fd

Browse files
committed
add host ID variable
1 parent 41e305d commit 9ef24fd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/aws-macos/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ EOT
1313
sensitive = true
1414
}
1515

16+
variable "dedicated_host_id" {
17+
description = "Dedicated host ID: (leave blank to create a new one)"
18+
default = false
19+
type = string
20+
}
21+
1622
variable "secret_key" {
1723
description = <<EOT
1824
AWS Secret Key
@@ -21,6 +27,7 @@ EOT
2127
}
2228

2329
resource "aws_ec2_host" "dedicated" {
30+
count = var.dedicated_host_id == "" ? 1 : 0
2431
instance_type = "mac1.metal"
2532
availability_zone = "us-west-2a"
2633
host_recovery = "off"
@@ -85,7 +92,7 @@ EOT
8592
resource "aws_instance" "dev" {
8693
ami = data.aws_ami.mac.id
8794
availability_zone = "us-west-2a"
88-
host_id = aws_ec2_host.dedicated.id
95+
host_id = var.dedicated_host_id == "" ? aws_ec2_host.dedicated[0].id : var.dedicated_host_id
8996
instance_type = "mac1.metal"
9097
count = 1
9198

0 commit comments

Comments
 (0)