0

尝试使用 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 

并且 policy.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"
        }
      }
    }
  ]
}
4

1 回答 1

2

您应该file://按照以下说明使用:

因此,如果policy.json在当前工作目录中,您可以尝试以下操作:

aws iam create-role --path /role-service/ --role-name Test-Role --assume-role-policy-document file://policy.json 
于 2020-10-02T07:23:23.180 回答