terraform - 如何为 Terraform 提供程序模式的 2 个字段编写 ValidateFunc?
问题描述
我正在编写一个自定义提供程序,其中我在架构中定义了 2 个字段,即:host_instance_type 和 storage_capacity。为不同 host_instance_type 的行为不同的 storage_capacity 编写验证函数的最佳方法是什么?在此 storage_capacity,必须只为特定的 host_instance_type(比如 A)指定。但是不应为 host_instance_type 指定 storage_capacity(比如 B)。
解决方案
ValidateFunc
,不幸的是,仅将其定义为参数的字段。
但是,您可以在资源本身的 CRUD(创建、读取、更新、删除)逻辑中执行验证逻辑。例如,查看 AWS 的 lambda 函数资源如何在其“创建”函数中执行验证:https ://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_lambda_function.go#L297
推荐阅读
- python - python,通过基于 Web 的应用程序在浏览器中运行具有多个踏板的 selenium
- elasticsearch - 如何索引复杂的逻辑表达式?
- react-native - 如何自动打开表情符号键盘?[反应原生]
- amazon-web-services - 使用 @SqsListener 时 Spring Boot 应用程序启动失败
- bash - 列出远程服务器上的文件并检索自 10 分钟以来未修改的文件
- c++ - boost::asio::write 上的互斥锁不起作用
- ruby-on-rails - 使用 SmarterCSV 时有没有办法忽略带有空标题的列?
- google-apps-script - Google表格中的加权随机
- pandas - 从数据帧中提取索引并附加到另一个数据帧
- android - Kotlin - 添加更多变体 - soundPool