로컬에서 DynamoDB를 써보자

최대 1 분 소요

로컬에서 DynamoDB 사용해보기

찾아보거나 알게된 배경

비동기에서 데이터 저장을 DynamoDB로 할 예정이라 관련 정보를 찾아봤었다.


요약

아래 참고자료에 있는 링크로 접속하여, docker compose를 가져와서 실행한 후, endpoint_url만 변경해주면 된다.

  • Python Code Example
    client = boto3.client(
        "dynamodb",
        aws_access_key_id="fake",
        aws_secret_access_key="fake",
        endpoint_url="<http://localhost:4566>",
    )
    
  • AWS CLI Example
    aws dynamodb describe-table --table-name=test-serverless --endpoint-url <http://localhost:18000>
    
  • 결과
    {
        "Table": {
            "AttributeDefinitions": [
                {
                    "AttributeName": "id",
                    "AttributeType": "S"
                },
                {
                    "AttributeName": "sort",
                    "AttributeType": "S"
                }
            ],
            "TableName": "test-serverless",
            "KeySchema": [
                {
                    "AttributeName": "id",
                    "KeyType": "HASH"
                },
                {
                    "AttributeName": "sort",
                    "KeyType": "RANGE"
                }
            ],
            "TableStatus": "ACTIVE",
            "CreationDateTime": "2022-08-18T18:37:41.370000+09:00",
            "ProvisionedThroughput": {
                "LastIncreaseDateTime": "1970-01-01T09:00:00+09:00",
                "LastDecreaseDateTime": "1970-01-01T09:00:00+09:00",
                "NumberOfDecreasesToday": 0,
                "ReadCapacityUnits": 0,
                "WriteCapacityUnits": 0
            },
            "TableSizeBytes": 0,
            "ItemCount": 0,
            "TableArn": "arn:aws:dynamodb:ddblocal:000000000000:table/test-serverless",
            "BillingModeSummary": {
                "BillingMode": "PAY_PER_REQUEST",
                "LastUpdateToPayPerRequestDateTime": "2022-08-18T18:37:41.370000+09:00"
            }
        }
    }
    

참고자료