首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对全局辅助索引的权限

对全局辅助索引的权限
EN

Stack Overflow用户
提问于 2018-11-07 22:16:54
回答 1查看 4.8K关注 0票数 6

我使用samdynamodb表定义为这样:

代码语言:javascript
复制
#DynamoTables
  DevicesTable:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: devices
      AttributeDefinitions:
        - 
          AttributeName: "id"
          AttributeType: "S"
        - 
          AttributeName: "customerId"
          AttributeType: "S"
      KeySchema:
        - 
          AttributeName: "id"
          KeyType: "HASH"
        -
          AttributeName: "customerId"
          KeyType: "RANGE"
      GlobalSecondaryIndexes: 
        - 
          IndexName: "customers"
          KeySchema: 
            - 
              AttributeName: "customerId"
              KeyType: "HASH"
          Projection: 
            ProjectionType: "ALL"   
          ProvisionedThroughput: 
            ReadCapacityUnits: "5"
            WriteCapacityUnits: "5"
      ProvisionedThroughput:
        ReadCapacityUnits: "5"
        WriteCapacityUnits: "5"

我能够使用带有sam中定义的Properties: Policies: AmazonDynamoDBFullAccess的lambda函数访问表,并在node中使用TableName: 'devices'定义put参数。但是,当我试图通过将索引定义为这样的查询来查询索引时:

代码语言:javascript
复制
params = {
  TableName: 'devices',
  IndexName: 'customers'
  // ...
}

我得到一个错误,说明lambda函数没有访问该索引的权限:

用户: arn:aws:sts:::assumed-role/CodeStarWorker-Lambda/awscodestar-lambda-DeviceFunction未被授权执行:dynamodb:查询资源:TABLEURL/设备/索引/客户

有人知道我可以授予这个访问权或者绕过这个方法来查询索引吗?

更新:我不认为AmazonDynamoDBFullAccess策略会影响到任何事情,当我从template.yml中删除它时,我仍然能够放到表中,仍然无法查询索引。我必须手动添加角色吗?

EN

回答 1

Stack Overflow用户

发布于 2019-06-03 21:06:01

您的lambda可以访问TABLEURL/设备,但不能访问TABLEURL/设备/index/customers。

以下是aws文档中的一个示例,说明如何允许访问数据库的所有索引。

代码语言:javascript
复制
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AccessAllIndexesOnBooks",
            "Effect": "Allow",
            "Action": [
                "dynamodb:*"
            ],
            "Resource": [
                "arn:aws:dynamodb:us-west-2:123456789012:table/Books",
                "arn:aws:dynamodb:us-west-2:123456789012:table/Books/index/*"
            ]
        }
    ]
}
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53198712

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档