amazon-web-services - AWS 创建角色 - 具有禁止字段

标签 amazon-web-services amazon-s3 amazon-iam aws-cli

我正在尝试 AWS 文档建议的一个简单示例,以使用策略 json 文件创建角色 http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html 我收到错误

A client error (MalformedPolicyDocument) occurred when calling the CreateRole operation: Has prohibited field Resource

这是命令,

>> aws iam create-role --role-name test-service-role --assume-role-policy-document file:///home/ec2-user/policy.json
A client error (MalformedPolicyDocument) occurred when calling the CreateRole operation: Has prohibited field Resource

该策略与示例中提到的策略完全相同

>> cat policy.json 
{
  "Version": "2012-10-17",
  "Statement": {
    "Effect": "Allow",
    "Action": "s3:ListBucket",
    "Resource": "arn:aws:s3:::example_bucket"
  }
}

我的版本似乎是最新的

>> aws --version
aws-cli/1.9.9 Python/2.7.10 Linux/4.1.10-17.31.amzn1.x86_64 botocore/1.3.9

最佳答案

政策文件应该类似于:

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

这称为信任关系策略文档。这与政策文件不同。您粘贴的内容都是针对附加到角色的策略,该角色是使用 attach role policy 完成的。

甚至上述角色文档也在您粘贴的链接中给出。 这应该有效。我已经研究过角色和政策,我可以肯定地说。

即使在 AWS 控制台中,对于角色,您也可以看到有一个单独的信任关系选项卡。此外,您当前已在权限选项卡中附加策略。

关于amazon-web-services - AWS 创建角色 - 具有禁止字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34188013/

相关文章:

python - aws s3下载文件

java - 使用 AWS S3 Java 将 ZipOutputStream 上传到 S3 而无需将 zip 文件(大)临时保存到磁盘

amazon-web-services - 调用 CreatePolicy 操作时出现 MalformedPolicyDocument - AWS

amazon-web-services - 无法仅使用 cloudformation 创建 IAM 策略

java - AWS Lambda 热函数重新发送代码,如何停止?

amazon-web-services - 如何使用预签名 URL 限制上传到 AWS S3 服务的文件的大小

r - AWS lambda R 运行时段错误

mysql - 如何与其他团队成员共享MySQL数据库

ruby - 尝试存储临时文件时的 Aws::S3::Errors::BadDigest

amazon-web-services - 如何将 IAM 角色分配给用户或组