Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@fkana

CloudFormationでDynamoDB作成時にハマったこと

AWSのリファレンスを読みながら作成したのに、少しハマったので・・

最初に書いたコード

  • 実行してもDynamoDBが作成されません
yaml
---
AWSTemplateFormatVersion: 2010-09-09
Description: DynamoDB Crete
Parameters:
  TableName:
    Type: String
    Description: DDB Table Name
Resources:
  DDBTable:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: !Ref TableName
      AttributeDefinitions:
        -
          AttributeName: CreatedId
          AttributeType: S
      KeySchema:
        -
          AttributeName: CreatedId
          KeyType: HASH
Outputs:
  DynamoDBTableName:
    Value:
      !Ref DDBTable
    Description: DynamoDB Table Name
  • プロパティで「必須:はい」のものを全て指定してもうまく実行されない
  • スクリーンショット 2019-03-31 0.45.58.png

よく読んだら、デフォルトで入る値によって、必須となるパラメータがあった

  • BillingModeがデフォルトでPROVISIONEDに設定され、その設定の場合、ProvisionedThroughtputの記述が必須になる
  • スクリーンショット 2019-03-31 0.48.29.png
  • スクリーンショット 2019-03-31 0.49.43.png

正しいコード

  • うまくいった
yaml
---
AWSTemplateFormatVersion: 2010-09-09
Description: DynamoDB Crete
Parameters:
  TableName:
    Type: String
    Description: DDB Table Name
Resources:
  DDBTable:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: !Ref TableName
      AttributeDefinitions:
        -
          AttributeName: CreatedId
          AttributeType: S
      KeySchema:
        -
          AttributeName: CreatedId
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 3
        WriteCapacityUnits: 3
Outputs:
  DynamoDBTableName:
    Value:
      !Ref DDBTable
    Description: DynamoDB Table Name
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
4
Help us understand the problem. What are the problem?