Я новичок в Terraform и успешно создал спотовые экземпляры с помощью aws_spot_instance_request. Единственная проблема в том, что они воссоздаются (как и мои спотовые экземпляры ec2) в каждом приложении. Есть намёк на это? Ткс! id и metadata_options принудительное воссоздание (см. Ниже).
Terraform v0.11.14 | провайдер. aws v2.60.0
resource "aws_spot_instance_request" "machine_host" {
count = 2
ami = "${var.machine_ami}"
key_name = "${var.key_name}"
instance_type = "${var.machine_instance_type}"
iam_instance_profile = "${var.aws_iam_instance_profile_id}"
monitoring = "${var.use_detailed_monitoring}"
wait_for_fulfillment = true
instance_interruption_behaviour = "stop"
root_block_device {
volume_size = "${var.volume_size}"
volume_type = "${var.volume_type}"
delete_on_termination = true
}
vpc_security_group_ids = [
"${element(data.aws_security_groups.sg1.ids, 0)}",
"${element(data.aws_security_groups.sg2.ids, 0)}",
]
subnet_id = "${element(data.aws_subnet_ids.private.ids, 0)}"
tags = "${merge(
local.common_tags,
local.system_tags,
map(
"Name", "${var.machine_name}-${var.environment_name}-${count.index}",
"Type", "${var.machine_name}",
"Resource", "ec2",
)
)}"
provisioner "local-exec" {
command = "../../files/update_spotinstance_tags.sh ${var.aws_region} ${self.id} ${self.spot_instance_id}"
}
}
> -/+ module.backend.aws_spot_instance_request.machine_host[1] (new resource required)
> id: "sir-ht6sgc1h" => <computed> (forces new resource)
> ami: "ami-b70554c8" => "ami-b70554c8"
> arn: "" => <computed>
> associate_public_ip_address: "false" => <computed>
> availability_zone: "" => <computed>
> cpu_core_count: "" => <computed>
> cpu_threads_per_core: "" => <computed>
> ebs_block_device.#: "0" => <computed>
> ephemeral_block_device.#: "0" => <computed>
> get_password_data: "false" => "false"
> host_id: "" => <computed>
> iam_instance_profile: "dev-email-backend" =>
> "dev-email-backend"
> instance_interruption_behaviour: "stop" => "stop"
> instance_state: "" => <computed>
> instance_type: "t3.micro" => "t3.micro"
> ipv6_address_count: "0" => <computed>
> ipv6_addresses.#: "0" => <computed>
> key_name: "backend-email-stg" => "backend-email-stg"
> metadata_options.#: "" => <computed> (forces new resource)
> monitoring: "false" => "false"