6
4

More than 5 years have passed since last update.

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

Last updated at Posted at 2019-03-30

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
6
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4