You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Terraform:如何在选项组的选项中添加多个option_settings

Terraform AWS RDS选项组多配置值问题解决

问题重现

尝试创建RDS选项组时,为单个选项添加多个配置值,最初使用了列表形式的配置:

option {
    option_name = "VALID_OPTION_NAME"
    option_settings = [
      {
        name  = "foobar1"
        value = "foobar1"
      },
      {
        name  = "foobar2"
        value = "foobar2"
      },
      {
        name  = "foobar3"
        value = "foobar3"
      },
      {
        name  = "foobar4"
        value = "foobar4"
      },
      {
        name  = "foobar5"
        value = "foobar5"
      }
    ]
  }

执行terraform validate后触发错误:

on rds.tf line 112, in resource "aws_db_option_group" "rds-option-group":
 112:     option_settings = [

An argument named "option_settings" is not expected here. Did you mean to
define a block of type "option_settings"?

注:AWS控制台原生支持单个选项添加多配置,因此Terraform必然有对应实现,但官方文档无相关示例,且未使用第三方模块的情况下,现有讨论线程无法提供有效帮助。

正确配置方案

option_settings是Terraform AWS Provider中aws_db_option_group资源的嵌套块,而非普通参数,需通过重复定义块的方式添加多组配置:

option {
    option_name = "xx"
    option_settings {
      name  = "xx"
      value = "xx"
    }
    option_settings {
      name  = "xx"
      value = "xx"
    }
    option_settings {
      name  = "xx"
      value = "xx"
    }
    option_settings {
      name  = "xx"
      value = "xx"
    }
  }

内容的提问来源于stack exchange,提问作者numbersgoup

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 02:55:23