【发布时间】:2020-10-20 01:15:23
【问题描述】:
我想在 Terraform 中创建 Auto Scaling 组并通过数据获取现货价格并使用更新的现货价格创建启动模板,例如:
resource "aws_launch_template" "launch_cfg_spot" {
count = length(var.pricing)
name_prefix = "launch_cfg_spot_${count.index}"
instance_type = var.pricing[count.index].InstanceType
image_id = "ami-0ff8a91507f77f867"
instance_market_options {
market_type = "spot"
spot_options {
max_price = var.pricing[count.index].price
}
}
network_interfaces{
subnet_id = var.subnets[var.pricing[count.index].az]
}
}
我现在使用 boto3 中的 describe_spot_price_history 命令使用外部脚本实现了它,但我确信有一种方法可以通过 Terraform 获取价格
【问题讨论】:
-
唯一想到的数据是
aws_pricing_productregistry.terraform.io/providers/hashicorp/aws/latest/docs/… -
只返回 "AttributeValues": [ { "Value": "OnDemand" }, { "Value": "Reserved" } ],里面没有点:(
-
你可以分享你使用的过滤器
标签: amazon-web-services terraform terraform-provider-aws