UPD: added back spot instance support
This commit is contained in:
parent
5a9f2e08c6
commit
a112747c14
@ -27,6 +27,21 @@ resource "aws_instance" "ec2-instance" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# spot instance option
|
||||||
|
dynamic "instance_market_options" {
|
||||||
|
for_each = var.spot-max-price > 0 ? { use_spot : true } : {}
|
||||||
|
content {
|
||||||
|
market_type = "spot"
|
||||||
|
|
||||||
|
dynamic "spot_options" {
|
||||||
|
for_each = { use_spot : true }
|
||||||
|
content {
|
||||||
|
max_price = var.spot-max-price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
disable_api_termination = var.enable-termination-protection
|
disable_api_termination = var.enable-termination-protection
|
||||||
user_data = var.user-data
|
user_data = var.user-data
|
||||||
monitoring = var.enable-detail-monitoring
|
monitoring = var.enable-detail-monitoring
|
||||||
|
@ -94,4 +94,9 @@ variable "enable-detail-monitoring" {
|
|||||||
type = bool
|
type = bool
|
||||||
default = false
|
default = false
|
||||||
description = "Set true to enable detail monitoring"
|
description = "Set true to enable detail monitoring"
|
||||||
|
}
|
||||||
|
variable spot-max-price {
|
||||||
|
type = number
|
||||||
|
description = "Max hourly price for spot instance. If greater than zero, spot instance will be used."
|
||||||
|
default = 0
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user