AWS create role - Has prohibited field

前端 未结 2 400
迷失自我
迷失自我 2020-12-29 17:41

I am trying out a simple example suggested by AWS documentation to create a role using a policy json file http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for

相关标签:
2条回答
  • 2020-12-29 18:18

    The AWS message, An error occurred (MalformedPolicyDocument) when calling the CreateRole operation: This policy contains invalid Json appears if you don't use the full pathname. For instance, using

    --assume-role-policy-document myfile.json
    

    or even a nonexistent.file.json, causes the problem.

    The solution is to use

    --assume-role-policy-document file://myfile.json
    

    An here is the content for my Kinesis Firehose Delivery Stream

    {
     "Version": "2012-10-17",
     "Statement": {
       "Effect": "Allow",
       "Principal": {"Service": "firehose.amazonaws.com"},
       "Action": "sts:AssumeRole"
      }
    } 
    
    0 讨论(0)
  • 2020-12-29 18:27

    The policy document should be something like:

    {
      "Version": "2012-10-17",
      "Statement": {
        "Effect": "Allow",
        "Principal": {"Service": "ec2.amazonaws.com"},
        "Action": "sts:AssumeRole"
      }
    }
    

    This is called a trust relationship policy document. This is different from a policy document. Whatever you have pasted is for the policy attached to a role which is done using attach role policy

    Even the above role document is given in the link you have pasted. This should work. I have worked on roles and policies and I can say with certainty.

    Even in the AWS console, for roles you can see that there is a separate tab for trust relationship. Also you have currently attached policies in the permissions tab.

    0 讨论(0)
提交回复
热议问题