0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GitHub Actions で DynamoDB Local を使う

Posted at

GitHub Actions で DynamoDB Local を使う方法について調べると、mooyoul/dynamodb-actionsrrainn/dynamodb-action を使う方法は出てくるんだけど、サードパーティのアクションを使わずにできるのでメモ。

やることは簡単で、

  1. GitHub Actionsのサービスコンテナ として dynamodb-local を起動
  2. dynamodb-local に aws dynamodb create-table する

だけ。

example.yml
name: Some Job Using DynamoDB

jobs:
  some_job_using_dynamodb_local:
    runs-on: ubuntu-latest

    # services で localhost:8000 で dynamodb-local を起動する
    services:
      dynamodb:
        image: amazon/dynamodb-local
        ports:
          - 8000:8000

    steps:
      - name: Setup DynamoDB Local
        env:
          AWS_ACCESS_KEY_ID: dummy
          AWS_SECRET_ACCESS_KEY: dummy
          AWS_DEFAULT_REGION: ap-northeast-1
        # create-table とかする
        # https://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/Tools.CLI.html
        run: |
          aws dynamodb create-table --endpoint-url http://localhost:8000 \
            --table-name your_table_name \
            --attribute-definitions AttributeName=hoge,AttributeType=S \
            --key-schema AttributeName=hoge,KeyType=HASH \
            --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1

      - name: Check DynamoDB Table
        env:
          AWS_ACCESS_KEY_ID: dummy
          AWS_SECRET_ACCESS_KEY: dummy
          AWS_DEFAULT_REGION: ap-northeast-1
        run: aws dynamodb describe-table --endpoint-url http://localhost:8000 --table-name your_table_name
        

create-table する対象が増えてきたら何か工夫しないといけなそう。

リンク

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?