【问题标题】:Unsupported argument, An argument named "" is not expected here不支持的参数,此处不应使用名为“”的参数
【发布时间】:2021-11-23 08:35:04
【问题描述】:

我在运行 terraform plan 时遇到以下错误,这个 IAM 的想法是允许 Lambda 在完成执行后在 AWS 中运行其他服务(步进函数)。

为什么 terraform 会失败并显示“此处不应有名为“”的参数”?

地形版本

Terraform v0.12.31

错误

Error: Unsupported argument

  on iam.tf line 246, in resource "aws_iam_role" "lambda_role":
 246:   managed_policy_arns = var.managed_policy_arns

An argument named "managed_policy_arns" is not expected here.


Error: Unsupported block type

  on iam.tf line 260, in resource "aws_iam_role" "lambda_role":
 260:   inline_policy {

Blocks of type "inline_policy" are not expected here.

iam.tf 的代码:-

resource "aws_iam_role" "lambda_role" {
  name = "${var.name}-role"
  managed_policy_arns = var.managed_policy_arns
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Principal = {
          Service = "lambda.amazonaws.com"
        }
      },
    ]
  })

  inline_policy {
    name    = "step_function_policy"
    policy  = jsonencode({
        Version = "2012-10-17"
        Statement: [
            {
                Effect: "Allow"
                Action: ["states:StartExecution"]
                Resource: "*"
            }
        ]
    })
    }
}

【问题讨论】:

  • 您的 AWS 提供商版本是什么?
  • @Marcin,谢谢你,Marcin,你的问题帮助了我

标签: terraform cloud terraform-provider-aws


【解决方案1】:

对于未来,我通过使用更高版本的 aws 提供程序解决了这个问题

provider.tf 如下所示:-

provider "aws" {
 region  = var.region
 version = "< 3.0"
}

把它改成这样:-

provider "aws" {
  region  = var.region
  version = "<= 3.37.0"
}

【讨论】:

    猜你喜欢
    • 2021-10-06
    • 2022-01-09
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 2018-10-11
    • 2012-04-01
    相关资源
    最近更新 更多