【问题标题】:Terraform Spot Instance inside VPCVPC 内的 Terraform Spot 实例
【发布时间】:2015-12-04 03:49:38
【问题描述】:

我正在尝试使用 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 中将此作为问题打开,但没有人回复我。

【问题讨论】:

  • 如果您怀疑这是一个错误,那么我不确定您会从 SO 中获得比项目所属的 github 存储库更多的东西。

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


【解决方案1】:

这是terraform中的一个错误,似乎已在master中修复。

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

【讨论】:

  • 似乎很难过您会发布“它的错误”而没有错误编号。你有没有打开过错误?
  • @JimmyDean 对不起,我已经修好了。
猜你喜欢
  • 2021-05-04
  • 2018-07-07
  • 2020-11-02
  • 1970-01-01
  • 2019-12-10
  • 2016-06-13
  • 2017-08-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多