amazon-web-services - 创建 IAM 角色时出错 - 属性 PolicyDocument 的值必须是对象

标签 amazon-web-services yaml aws-cloudformation amazon-kinesis

我正在创建一个 IAM 角色,以便将日志从一个堆栈发送到另一个堆栈中的 kinesis 流。 当我添加权限策略时,它失败并出现错误:

"Value of property PolicyDocument must be an object".

这是我的cloudformation.template.yml:

  KinesisRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: {'Fn::Sub': 'Kinesis-Role-${AWS::Region}'}
      AssumeRolePolicyDocument:
        Statement:
        - Effect: Allow
          Principal:
            Service: [logs.amazonaws.com]
          Action: ['sts:AssumeRole']
      Policies:
      - PolicyName: KinesisPolicy
        PolicyDocument:
        - Version: '2017-10-17'
          Statement:
          - Action: ['kinesis:PutRecord']
            Effect: Allow
            Resource: '*'

最佳答案

由于 Version 前面有 -,因此您当前的 PolicyDocument 是一个对象列表。另外您的版本也是错误的。所以应该是:

 KinesisRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: {'Fn::Sub': 'Kinesis-Role-${AWS::Region}'}
      AssumeRolePolicyDocument:
        Statement:
        - Effect: Allow
          Principal:
            Service: [logs.amazonaws.com]
          Action: ['sts:AssumeRole']
      Policies:
      - PolicyName: KinesisPolicy
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Action: ['kinesis:PutRecord']
            Effect: Allow
            Resource: '*'

关于amazon-web-services - 创建 IAM 角色时出错 - 属性 PolicyDocument 的值必须是对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66256445/

相关文章:

amazon-web-services - aws elastic beanstalk不调用私有(private)API

amazon-web-services - 从 S3 检索数据非常慢

amazon-web-services - 如何使用 YAML CloudFormation 模板在 API Gateway V2 资源上添加标签

amazon-web-services - Userdata Cloudformation 中资源的引用 ID

bash - 如何在CloudFormation中传入UserData作为参数

java - 使用 DynamoDB 处理时间序列数据并实现可视化目标

amazon-web-services - AWS API Gateway部署的API无法解析请求正文

csv - 将 YAML(或类似文件)转换或导入到 Google 电子表格(或 CSV)

python - YAML - 替换变量的值?

amazon-web-services - 出现错误 : Resource handler returned message: "AWS WAF couldn' t perform the operation because your resource doesn? t 存在