variable "iam_action" {
type = "list"
default = ["ec2.amazonaws.com","ecs.amazonaws.com"]
}
resource "aws_iam_role" "s3_role" {
name = "abcd"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": [ "${var.iam_action}"
]
},
"Effect": "Allow,
"Sid": ""
}
]
}
EOF
}
エラー資源に取得テラフォーム:機能に参加し、私は機能に参加してみましたが、私はリスト["a","b","c"]
する出力を必要とするリスト変数が
At column 1, line 1: output of an HIL expression must be a string, or a single list (argument 2 is TypeList) in:
は私がすることによってjsonencode
で固定し["a,b,c"]
'' 'assume_role_policy: ""=> "{\ nは\" バージョン\ ":" 2012年10月17日\」\ \ n \ "サービス\":\ "\" \ "\" \ "\" \ \ n "\ n" \ n "\ n" \ n "create_date : "" => "" "エラー:* aws_iam_role.s3_role:IAMロールの作成中にエラーが発生しましたs3_sysops_role:MalformedPolicyDocument:ポリシーの無効なプリンシパル:" SERVICE ":" $ {var.iam_action} " –
user60679
$ {foo }私はfoo = ["a"、 "b"、 "c"]をレンダリングしません。 – user60679
@ user60679答えを修正して更新しました。 – BMW