amazon-web-services - 计数=真。适用于 terraform 11 但不适用于 terrafom 12
问题描述
我正在升级到 terraform 12 并面临一些问题。我们有一个自动缩放模块(非根),它调用中央存储库(根)中的另一个模块。所以这个模块;
module "cef_fleet" {
source = "git::ssh://git@github.com/asg-repo.git?ref=terraform12"
instance_type = var.instance_type
ami = var.ami
etc ...
调用存储库“asg-repo”,在这里一些资源具有计数功能,例如;
resource "aws_autoscaling_schedule" "schedule_stop" {
count = var.create_resource * var.auto_stop
中央存储库中的这两个变量都设置为“真”。这适用于 terraform 11,但是当我升级到 12 时,我现在得到了错误;
var.create_resource is true
Unsuitable value for left operand: number required.
解决这个问题的方法是简单地用 1 替换真实值吗?或者应该是类似的东西;
count = signum(count = var.create_resource * var.auto_start) - where both are also 1?
解决方案
使用三元运算符:
count = var.create_resource && var.auto_start ? 1 : 0
推荐阅读
- python - 解析 HTML 以检索术语
- jquery - 使用来自html的flask和jquery将数据传递到mySQL数据库
- neo4j - 密码查询以查找多个节点之间的所有关系
- laravel - 未定义变量:post(查看:E:\xamp\htdocs\lsapp\resources\views\posts\index.blade.php)
- windows - 如何将 windows phone 模拟器添加到 uwp 项目
- python - 从 pandas 索引中选择元素
- python - 生成具有重复率的 numpy 数组
- android - Android(Java)中包含英语、希伯来语和数字的字符串中的 RTL 问题
- json - Instagram publick 个人资料数据
- ruby-on-rails - 从 docker 容器共享 unix 套接字到 ubuntu 主机