如何修复 MalformedPolicyDocument

how to fix MalformedPolicyDocument

我正在尝试创建一个信任策略,该策略仅授予特定角色访问权限以承担其角色{角色链接},但是当我 运行 terraform 时,我收到以下错误消息

更新 IAM 角色 (GitActions_Workflow_role) 承担角色策略时出错:MalformedPolicyDocument:策略中的主体无效:“AWS”:“arn:aws:iam::12345678910:role/Orchestration_Role”

请问如何创建只授予另一个角色代入它的信任策略角色?如何修复我的主体会话中的错误消息

resource "aws_iam_role" "GitHubActions" {
  name = var.role_name

  assume_role_policy = <<EOF
{
  "Version":"2012-10-17",
  "Statement": {
    "Effect": "Allow",
    "Principal": {
      "AWS":"arn:aws:iam::${var.oidc_account}:role/${var.orchestration_role_name}"
    },
    "Action": "sts:AssumeRole",
    "Condition": {}
  }
}
EOF 
}

variables.tf

variable "role_name"{
    type        = string
}


variable "managed_policy"{
    type        = string
}

variable "orchestration_role_name"{
    type = string
    default = "Orchestration_Role"
}

variable "oidc_account"{
    type = string
    default = "12345678910"
}

主要角色 必须存在 才能尝试使用它。如果尚未创建 Orchestration_Role,则无法创建 aws_iam_role.GitHubActions