仅在托管策略云形成时创建IAM角色

时间:2016-09-23 00:01:49

标签: amazon-cloudformation

我正在尝试使用现有的maneged政策创建IAM角色:

"SomeRole": 
        {
            "Type": "AWS::IAM::Role",
            "Properties": 
            {
                "AssumeRolePolicyDocument": {},
                "ManagedPolicyArns": 
                [
                    "arn:aws:iam::aws:policy/AmazonKinesisReadOnlyAccess",
                    "arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess",
                    "arn:aws:iam::aws:policy/CloudWatchFullAccess"
                ],

                "RoleName": "SomeRole"
            }
        },

但它失败了,错误:位置(1,3)的语法错误

1 个答案:

答案 0 :(得分:14)

看起来你必须在AssumeRolePolicyDocument中有一些价值。

试试这个。

{
  "Resources": {
    "NewRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "ec2.amazonaws.com"
                ]
              },
              "Action": [
                "sts:AssumeRole"
              ]
            }
          ]
        },
        "ManagedPolicyArns": [
          "arn:aws:iam::aws:policy/AmazonKinesisReadOnlyAccess",
          "arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess",
          "arn:aws:iam::aws:policy/CloudWatchFullAccess"
        ]
      }
    }
  }
}