본문 바로가기
Web/AWS

[ AWS ] DynamoDB Local 환경 구축 오류

by 기저귀찬개발자 2020. 5. 7.

GeoData 테스트를 위해서 DynamoDB Local 생성 중 생긴 오류 이다 

아래는 생성 exam source이다. (원본 소스 : https://github.com/rh389/dynamodb-geo.js#readme)

const ddbGeo = require('dynamodb-geo');
const AWS = require('aws-sdk');
const uuid = require('uuid');

// Set up AWS
AWS.config.update({
    accessKeyId: '--',
    secretAccessKey: '--',
    region: 'ap-northeast-2'
});

// Use a local DB for the example.
const ddb = new AWS.DynamoDB({ endpoint: new AWS.Endpoint('http://localhost:8000') });

const config = new ddbGeo.GeoDataManagerConfiguration(ddb, 'test');

const capitalsManager = new ddbGeo.GeoDataManager(config);

// Use GeoTableUtil to help construct a CreateTableInput.
const createTableInput = ddbGeo.GeoTableUtil.getCreateTableRequest(config);

// Tweak the schema as desired
createTableInput.ProvisionedThroughput.ReadCapacityUnits = 5;

// Create the table
ddb.createTable(createTableInput).promise()
    .then(function () { return ddb.waitFor('tableExists', { TableName: config.tableName }).promise() })
    .then(console.log)
    .catch(console.warn)
    .then(function () {
        process.exit(0);
    });

 

아래는 오류 결과 소스이다.

{ Error: connect ECONNREFUSED 127.0.0.1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
  message: 'connect ECONNREFUSED 127.0.0.1:8000',
  errno: 'ECONNREFUSED',
  code: 'NetworkingError',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8000,
  region: 'ap-northeast-2',
  hostname: 'localhost',
  retryable: true,
  time: 2020-05-07T14:13:29.819Z }

 

 

 

dynamodb list에도 보이지 않는다.( 아래와 같이 조회하면 local이 아닌 region에서 조회하기 때문에 나오지 않는다. 이땐 몰랐다..)

$ aws dynamodb list-tables
{
    "TableNames": []
}

 

사용중인 포트도 나오지 않는다.

netstat -tnlp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:36429         0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::8080                 :::*                    LISTEN      -                   
tcp6       0      0 :::80                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:631                 :::*                    LISTEN      -                   
tcp6       0      0 :::8888                 :::*                    LISTEN      -                   
tcp6       0      0 :::9999                 :::*                    LISTEN      -  

 

Local에 DynamoDB가 설치되지 않아서 였다.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html

 

 

 

설치 후 재시도하니 다른 오류가 나타났다.

{ Error: write EPROTO 140248418756416:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

    at WriteWrap.afterWrite [as oncomplete] (net.js:788:14)
  message:
   'write EPROTO 140248418756416:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:\n',
  errno: 'EPROTO',
  code: 'NetworkingError',
  syscall: 'write',
  region: 'ap-northeast-2',
  hostname: '127.0.0.1',
  retryable: true,
  time: 2020-05-07T15:47:51.066Z }

 

테스트 도중 http 프로토콜을 제거해서 생긴 문제였다.

//http 미입력시 https로 접근하여 인증되지 않아 오류가 발생했다.
const ddb = new AWS.DynamoDB({ endpoint: new AWS.Endpoint('127.0.0.1:8000') });

//소스를 원복하여 수정하였다.
const ddb = new AWS.DynamoDB({ endpoint: new AWS.Endpoint('http://localhost:8000') });

 

위 소스를 실행시켜보니 생성은 제대로 됐다고 나왔으나 table이 보이지 않았다.

이유는 뒤에 endpoint를 설정하지 않아 local을 참조하지 않고 aws region을 조회하여 생긴 문제였다. 

endpoint를 설정뒤엔 조회가 잘되었다.

$aws dynomodb aws dynamodb list-tables
{
    "TableNames": []
}

$aws dynamodb list-tables --endpoint-url "http://localhost:8000"
{
    "TableNames": [
        "footprint",
        "footprint2"
    ]
}

 

dynamodb local 환경 구축하다 멍청한 짓으로 헤맸었다. 다음번엔 기본적인 부분을 먼저 생각을 해야겠다 느꼈다. 

댓글