使用Cloud Cloud Formation创建本地辅助索引

发布于 2025-02-02 23:56:53 字数 981 浏览 2 评论 0原文

我的歉意,我从AWS和CloudFormation开始

,我得到了此云形成模板,我得到了ID主题作为主要索引,我想添加本地次要索引这包括id位置列到此模板。

ID主题位置DETAILLS
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  Env:
    Type: String
  CommitHash:
    Type: String

Resources:
  RecipeRecommendationDynamoDBTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: "id"
          AttributeType: "S"
        - AttributeName: "topic"
          AttributeType: "S"
      KeySchema:
        - AttributeName: "id"
          KeyType: "HASH"
        - AttributeName: "topic"
          KeyType: "RANGE"
      TimeToLiveSpecification:
        AttributeName: ttl
        Enabled: true
      TableName: topics_dumps
      BillingMode: PAY_PER_REQUEST
      Tags:
        - Key: "Env"
          Value: !Ref Env

My apologies I'm starting with AWS and Cloudformation

I got this cloud formation template, I got Id and topic as a primary index and I would like to add a local secondary index that consists of the id and position columns to this template.

Idtopicpositiondetaills
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  Env:
    Type: String
  CommitHash:
    Type: String

Resources:
  RecipeRecommendationDynamoDBTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: "id"
          AttributeType: "S"
        - AttributeName: "topic"
          AttributeType: "S"
      KeySchema:
        - AttributeName: "id"
          KeyType: "HASH"
        - AttributeName: "topic"
          KeyType: "RANGE"
      TimeToLiveSpecification:
        AttributeName: ttl
        Enabled: true
      TableName: topics_dumps
      BillingMode: PAY_PER_REQUEST
      Tags:
        - Key: "Env"
          Value: !Ref Env

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莳間冲淡了誓言ζ 2025-02-09 23:56:53

您必须添加 localsecondaryindexes

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  Env:
    Type: String
  CommitHash:
    Type: String

Resources:
  RecipeRecommendationDynamoDBTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: "id"
          AttributeType: "S"
        - AttributeName: "topic"
          AttributeType: "S"
        - AttributeName: "position"
          AttributeType: "S"          
      KeySchema:
        - AttributeName: "id"
          KeyType: "HASH"
        - AttributeName: "topic"
          KeyType: "RANGE"
      TimeToLiveSpecification:
        AttributeName: ttl
        Enabled: true
      LocalSecondaryIndexes: 
        - IndexName: position
          KeySchema: 
            - AttributeName: "id"
              KeyType: "HASH"
            - AttributeName: "position"
              KeyType: "RANGE"           
          Projection: 
            ProjectionType: ALL
      TableName: topics_dumps
      BillingMode: PAY_PER_REQUEST
      Tags:
        - Key: "Env"
          Value: !Ref Env

You have to add LocalSecondaryIndexes:

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  Env:
    Type: String
  CommitHash:
    Type: String

Resources:
  RecipeRecommendationDynamoDBTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: "id"
          AttributeType: "S"
        - AttributeName: "topic"
          AttributeType: "S"
        - AttributeName: "position"
          AttributeType: "S"          
      KeySchema:
        - AttributeName: "id"
          KeyType: "HASH"
        - AttributeName: "topic"
          KeyType: "RANGE"
      TimeToLiveSpecification:
        AttributeName: ttl
        Enabled: true
      LocalSecondaryIndexes: 
        - IndexName: position
          KeySchema: 
            - AttributeName: "id"
              KeyType: "HASH"
            - AttributeName: "position"
              KeyType: "RANGE"           
          Projection: 
            ProjectionType: ALL
      TableName: topics_dumps
      BillingMode: PAY_PER_REQUEST
      Tags:
        - Key: "Env"
          Value: !Ref Env
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文