尝试使用aws-cli创建新角色时出错。
这是错误消息。
An error occurred (MalformedPolicyDocument) when calling the CreateRole operation: This policy contains invalid Json
在另一个角色中,我运行以下命令。
aws iam create-role --path /role-service/ --role-name Test-Role --assume-role-policy-document policy.json
政策.json是
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "cognito-idp.amazonaws.com"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "d611c8fd-0fd1-469a-a5ea-b02186042023"
}
}
}
]
}
您应该使用file://
,如中所述
- 从文件加载AWS CLI参数
因此,如果当前工作目录中的policy.json
,您可以尝试以下操作:
aws iam create-role --path /role-service/ --role-name Test-Role --assume-role-policy-document file://policy.json