VPC 内的 Terraform Spot 实例
Terraform Spot Instance inside VPC
我正在尝试使用 Terraform 在 VPC 内启动一个 spot 实例。
我有一个有效的 aws_instance
设置,只是将其更改为 aws_spot_instance_request
,但我总是收到此错误:
* aws_spot_instance_request.machine: Error requesting spot instances: InvalidParameterCombination: VPC security groups may not be used for a non-VPC launch
status code: 400, request id: []
我的 .tf
文件如下所示:
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
resource "template_file" "userdata" {
filename = "${var.userdata}"
vars {
domain = "${var.domain}"
name = "${var.name}"
}
}
resource "aws_spot_instance_request" "machine" {
ami = "${var.amiPuppet}"
key_name = "${var.key}"
instance_type = "c3.4xlarge"
subnet_id = "${var.subnet}"
vpc_security_group_ids = [ "${var.securityGroup}" ]
user_data = "${template_file.userdata.rendered}"
wait_for_fulfillment = true
spot_price = "${var.price}"
tags {
Name = "${var.name}.${var.domain}"
Provider = "Terraform"
}
}
resource "aws_route53_record" "machine" {
zone_id = "${var.route53ZoneId}"
name = "${aws_spot_instance_request.machine.tags.Name}"
type = "A"
ttl = "300"
records = ["${aws_spot_instance_request.machine.private_ip}"]
}
我不明白为什么它不起作用...
documentation表示spot_instance_request
支持aws_instance
的所有参数,所以,我只是将一个有效的aws_instance
更改为spot_instance_request
(加上价格)。 ..我做错了什么吗?
我最初在 Terraform repo 中将此作为问题打开,但没有人回复我。
这是 terraform 中的一个错误,似乎已在 master 中修复。
我正在尝试使用 Terraform 在 VPC 内启动一个 spot 实例。
我有一个有效的 aws_instance
设置,只是将其更改为 aws_spot_instance_request
,但我总是收到此错误:
* aws_spot_instance_request.machine: Error requesting spot instances: InvalidParameterCombination: VPC security groups may not be used for a non-VPC launch
status code: 400, request id: []
我的 .tf
文件如下所示:
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
resource "template_file" "userdata" {
filename = "${var.userdata}"
vars {
domain = "${var.domain}"
name = "${var.name}"
}
}
resource "aws_spot_instance_request" "machine" {
ami = "${var.amiPuppet}"
key_name = "${var.key}"
instance_type = "c3.4xlarge"
subnet_id = "${var.subnet}"
vpc_security_group_ids = [ "${var.securityGroup}" ]
user_data = "${template_file.userdata.rendered}"
wait_for_fulfillment = true
spot_price = "${var.price}"
tags {
Name = "${var.name}.${var.domain}"
Provider = "Terraform"
}
}
resource "aws_route53_record" "machine" {
zone_id = "${var.route53ZoneId}"
name = "${aws_spot_instance_request.machine.tags.Name}"
type = "A"
ttl = "300"
records = ["${aws_spot_instance_request.machine.private_ip}"]
}
我不明白为什么它不起作用...
documentation表示spot_instance_request
支持aws_instance
的所有参数,所以,我只是将一个有效的aws_instance
更改为spot_instance_request
(加上价格)。 ..我做错了什么吗?
我最初在 Terraform repo 中将此作为问题打开,但没有人回复我。
这是 terraform 中的一个错误,似乎已在 master 中修复。