VPC内的Terraform竞价型实例

时间:2015-09-08 12:41:45

标签: amazon-web-services amazon-ec2 terraform

我正在尝试使用Terraform在VPC中启动一个现场实例。

我有一个有效的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}"]
}

我不明白为什么它不起作用...... spot_instance_request代表aws_instance支持aws_instance的所有参数,因此,我只是将工作spot_instance_request更改为Unable to copy icudt46l.zip file (添加了价格)。我做错了什么?

我最初在documentation打开了这个问题,但没有人回复我。

1 个答案:

答案 0 :(得分:0)

这是terraform中的一个错误,似乎在主人身上得到了修复。

https://github.com/hashicorp/terraform/issues/1339