Notice
Recent Posts
Recent Comments
Link
투케이2K
465. (javaScript) [간단 소스] 자바스크립트 AWS DynamoDB 다이나모 디비 테이블 정보 조회 수행 - DescribeTable 본문
JavaScript
465. (javaScript) [간단 소스] 자바스크립트 AWS DynamoDB 다이나모 디비 테이블 정보 조회 수행 - DescribeTable
투케이2K 2025. 12. 9. 19:59728x90
[개발 환경 설정]
개발 툴 : Edit++
개발 언어 : JavaScript
[소스 코드]
-----------------------------------------------------------------------------------------
[사전 설명 및 설정 사항]
-----------------------------------------------------------------------------------------
- 개발 환경 : Web
- 개발 기술 : JavaScript (자바스크립트) / AWS / Database / DynamoDB
- 사전) DynamoDB 간단 설명 :
>> Aws DynamoDB 는 모든 규모에서 10밀리초 미만의 성능을 제공하는 서버리스, NoSQL, 완전관리형 데이터베이스입니다 (서버리스 NoSQL 데이터베이스 서비스)
>> Aws DynamoDB 는 규모와 관계없이 일관된 성능이 필요한 운영 워크로드에 맞게 특별히 구축되고 최적화되었습니다.
>> Aws DynamoDB 특징 :
- Serverless (서버리스) : 서버를 프로비저닝하거나 소프트웨어를 패치, 관리, 설치, 유지 보수 또는 운영할 필요가 없으며, 가동 중지가 발생하지 않는 유지 관리를 제공합니다
- NoSQL :
$ 기존의 관계형 데이터베이스보다 향상된 성능, 확장성, 관리성 및 유연성을 제공하도록 특별히 구축되었습니다
$ 다양한 사용 사례를 지원하기 위해 DynamoDB 는 키-값 및 문서 데이터 모델을 모두 지원합니다
- 완전관리형 :
$ DynamoDB 는 설정, 구성, 유지 관리, 고가용성, 하드웨어 프로비저닝, 보안, 백업, 모니터링 등을 처리하며 테이블을 생성할 때 프로덕션 워크로드에 즉시 사용할 수 있습니다.
$ 또한, 업그레이드가 필요하지 않고 가동 중지가 발생하지 않으면서 가용성, 신뢰성, 성능, 보안 및 기능을 지속적으로 개선합니다
- 규모를 따지지 않는 한 자릿수 밀리초의 성능 :
$ DynamoDB 는 모든 규모에서 10밀리초 미만의 성능을 제공하여 관계형 데이터베이스의 성능과 확장성을 개선하기 위해 특별히 개발되었습니다.
$ DynamoDB 는 고성능 워크로드에 최적화되어 있으며 효율적인 데이터베이스 사용을 장려하는 API를 제공합니다 (JOIN 작업과 같이 규모에 비해 비효율적이고 성능이 떨어지는 기능은 생략됩니다)
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
[소스 코드]
-----------------------------------------------------------------------------------------
<!DOCTYPE HTML>
<html lang="ko">
<head>
<title>javaScriptTest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- 반응형 구조 만들기 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<!-- 내부 CSS 스타일 지정 -->
<style>
html, body {
width: 100%;
height: 100%;
margin : 0 auto;
padding : 0;
border : none;
background-color: #666;
}
</style>
<!-- [CDN 주소 설정] -->
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1416.0.min.js"></script>
<!-- [자바스크립트 코드 지정] -->
<script>
// --------------------------------------------------------------------------------------------------------------
// [전역 변수 선언]
const region = 'ap-northeast-2'; // [AWS 리전]
const accessKeyId = 'AK..A6'; // [IAM 액세스 키]
const secretAccessKey = 'mP..5J'; // [IAM 시크릿 키]
// [내부 클로저 선언 실시]
var innerFunction = null;
// --------------------------------------------------------------------------------------------------------------
// [html 최초 로드 및 이벤트 상시 대기 실시]
window.onload = async function() {
console.log("");
console.log("=========================================");
console.log("[window onload] : [start]");
console.log("=========================================");
console.log("");
// -----------------------------------------
// [초기 변수 초기화]
// -----------------------------------------
innerFunction = null;
// -----------------------------------------
// [AWS.config 지정]
// -----------------------------------------
// IAM 계정 정보를 사용해 AWS.config 정보 업데이트 수행
// -----------------------------------------
AWS.config.update({
region: region,
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey
});
// -----------------------------------------
// [AWS.DynamoDB 객체 생성]
// -----------------------------------------
const awsDB = new AWS.DynamoDB();
// -----------------------------------------
// [내부 클로저 함수 정의]
// -----------------------------------------
innerFunction = async function() {
try {
// -----------------------------------------
// [요청 파라미터 생성]
// -----------------------------------------
const param = {
TableName: 'iot_device' // ✅ 테이블 명칭
};
// -----------------------------------------
// [describeTable] : Aws DynamoDB 에 생성 되어 있는 테이블 정보 조회
// -----------------------------------------
// AWS 참고 사이트 : https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html
// -----------------------------------------
const [err, res] = await awsDB.describeTable( param ).promise()
.then(data => [null, data])
.catch(error => [error, null]);
if (err) {
console.error("");
console.error("=========================================");
console.error("[describeTable] : [Error]");
console.error("---------------------------------------");
console.error(err);
console.error("=========================================");
console.error("");
} else {
console.log("");
console.log("=========================================");
console.log("[describeTable] : [Result]");
console.log("---------------------------------------");
console.log(JSON.stringify(res));
console.log("=========================================");
console.log("");
// ---------------------------------------------
// ✅ [로그 출력 예시 첨부]
// ---------------------------------------------
/*
{
"Table": {
"AttributeDefinitions": [
{
"AttributeName": "status",
"AttributeType": "N"
},
{
"AttributeName": "device_id",
"AttributeType": "S"
},
{
"AttributeName": "mac_address",
"AttributeType": "S"
}
],
"TableName": "iot_device",
"KeySchema": [ // ✅ 파티션 키(HASH) / 소트 키(RANGE)
{
"AttributeName": "device_id",
"KeyType": "HASH"
},
{
"AttributeName": "mac_address",
"KeyType": "RANGE"
}
],
"TableStatus": "ACTIVE",
"CreationDateTime": "2024-12-16T08:40:58.569Z",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 0,
"WriteCapacityUnits": 0
},
"TableSizeBytes": 718686,
"ItemCount": 2548,
"TableArn": "arn:aws:dynamodb:ap-northeast-2:123456789012:table/iot_device",
"TableId": "b4c..028972c",
"BillingModeSummary": {
"BillingMode": "PAY_PER_REQUEST",
"LastUpdateToPayPerRequestDateTime": "2024-12-16T08:40:58.569Z"
},
"GlobalSecondaryIndexes": [
{
"IndexName": "iot_device_delstatus_index",
"KeySchema": [
{
"AttributeName": "mac_address",
"KeyType": "HASH"
},
{
"AttributeName": "status",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "INCLUDE",
"NonKeyAttributes": [
"expire_datetime",
"create_datetime",
"status",
"device_id",
"update_datetime",
"brand"
]
},
"IndexStatus": "ACTIVE",
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 0,
"WriteCapacityUnits": 0
},
"IndexSizeBytes": 718686,
"ItemCount": 2548,
"IndexArn": "arn:aws:dynamodb:ap-northeast-2:123456789012:table/iot_device/index/iot_device_delstatus_index"
}
],
"DeletionProtectionEnabled": false
}
}
*/
// ---------------------------------------------
// ---------------------------------------------
// [Table 정보 파싱 수행]
// ---------------------------------------------
if (res != null && res != undefined && res.hasOwnProperty("Table") == true){
console.warn("Parsing Table Info : ", JSON.stringify(res.Table));
}
else {
console.error("Parsing Table Error : Response Data Validation Error");
}
}
}
catch(exception){
console.error("");
console.error("=========================================");
console.error("[innerFunction] : [Exception] : ", exception);
console.error("=========================================");
console.error("");
}
};
// -----------------------------------------
// [내부 클로저 함수 호출]
// -----------------------------------------
innerFunction();
};
// --------------------------------------------------------------------------------------------------------------
</script>
</head>
<body>
</body>
</html>
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
[참고 사이트]
-----------------------------------------------------------------------------------------
[Aws NoSQL DynamoDB Service] Aws Dynamo DB 다이나모 디비 개념 및 설명 정리
https://kkh0977.tistory.com/7627
https://blog.naver.com/kkh0977/223734725747?trackingCode=blog_bloghome_searchlist
[Aws NoSQL DynamoDB Service] AWS 콘솔에서 다이나모 데이터베이스 ( Dynamo DB ) 테이블에 저장 된 데이터 조회 방법
https://blog.naver.com/kkh0977/223933617765?trackingCode=blog_bloghome_searchlist
[AWS] [Lambda] 런타임 Python 3.13 - boto3 모듈 사용해 다이나모 DB ( DynamoDB ) 테이블 목록 조회
https://blog.naver.com/kkh0977/223990664323
-----------------------------------------------------------------------------------------
728x90
반응형
'JavaScript' 카테고리의 다른 글
Comments
