dev.Log
DynamoDB랑 연동하기 본문
서비스 객체 생성 및 호출 - AWS SDK for JavaScript
이 페이지에 작업이 필요하다는 점을 알려 주셔서 감사합니다. 실망시켜 드려 죄송합니다. 잠깐 시간을 내어 설명서를 향상시킬 수 있는 방법에 대해 말씀해 주십시오.
docs.aws.amazon.com
var AWS = require('aws-sdk');
var documentClient = new AWS.DynamoDB.DocumentClient({
apiVersion:"2012-08-10"
});
const tableName = "Cards";
exports.handler = async (event) => {
console.log("Received: " + JSON.stringify(event,null,2));
let response = "";
try {
var params = {
TableName : tableName
};
const cards = await documentClient.scan(params).promise();
response = {
statusCode: 200,
body: JSON.stringify(cards)
};
} catch(exception) {
console.error(exception);
response = {
statusCode:500,
body : JSON.stringify({"Message":exception})
}
}
return response;
};
이렇게 하니까
2022-10-03T18:36:03.009Z f83c098c-5937-4a9c-bfb6-1a0f232cfb7f ERROR AccessDeniedException: User: arn:aws:sts::328625240517:assumed-role/getCard-role-rlsz4c4q/getCard is not authorized to perform: dynamodb:Scan on resource: arn:aws:dynamodb:ap-northeast-2:328625240517:table/Cards because no identity-based policy allows the dynamodb:Scan action
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)
이런 에러가 발생했다. => IAM 권한을 설정해줘야한다!!!
'AWS' 카테고리의 다른 글
역할생성 및 람다에 부여 (0) | 2022.10.04 |
---|---|
람다함수가 DynamoDB에 접근가능한 권한만들기 (0) | 2022.10.04 |
AWS 람다 (0) | 2022.10.03 |
CloudWatch와 SNS로 비용경보 만들기 (0) | 2022.10.03 |
CloudFront (0) | 2022.08.28 |
Comments