Uses Spot Only When Cost Is Configured
This commit is contained in:
@@ -51,7 +51,7 @@ variable "aws_ami" {
|
|||||||
|
|
||||||
variable "aws_spot_price" {
|
variable "aws_spot_price" {
|
||||||
type = number
|
type = number
|
||||||
default = 0.0028
|
default = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "cloudflare_api_token" {
|
variable "cloudflare_api_token" {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ variable "aws_ami" {
|
|||||||
|
|
||||||
variable "aws_spot_price" {
|
variable "aws_spot_price" {
|
||||||
type = number
|
type = number
|
||||||
default = 0.0028
|
default = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_public_key_main" {
|
variable "ssh_public_key_main" {
|
||||||
|
|||||||
@@ -115,13 +115,16 @@ resource "aws_instance" "worker" {
|
|||||||
instance_type = var.aws_instance_type
|
instance_type = var.aws_instance_type
|
||||||
vpc_security_group_ids = [aws_security_group.project_pool.id]
|
vpc_security_group_ids = [aws_security_group.project_pool.id]
|
||||||
count = var.number_of_workers
|
count = var.number_of_workers
|
||||||
|
|
||||||
instance_market_options {
|
dynamic "instance_market_options" {
|
||||||
market_type = "spot"
|
for_each = var.aws_spot_price != 0 ? [var.aws_spot_price] : []
|
||||||
spot_options {
|
content {
|
||||||
max_price = var.aws_spot_price
|
market_type = "spot"
|
||||||
instance_interruption_behavior = "stop"
|
spot_options {
|
||||||
spot_instance_type = "persistent"
|
max_price = instance_market_options.value
|
||||||
|
instance_interruption_behavior = "stop"
|
||||||
|
spot_instance_type = "persistent"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user