Notice
Recent Posts
Recent Comments
Link
투케이2K
494. (javaScript) 자바스크립트 AWS Lambda 함수 세부 정보 조회 수행 - GetFunction 본문
JavaScript
494. (javaScript) 자바스크립트 AWS Lambda 함수 세부 정보 조회 수행 - GetFunction
투케이2K 2026. 2. 23. 21:18728x90
반응형
[개발 환경 설정]
개발 툴 : Edit++
개발 언어 : JavaScript

[소스 코드]
-----------------------------------------------------------------------------------------
[사전 설명 및 설정 사항]
-----------------------------------------------------------------------------------------
- 개발 환경 : Web
- 개발 기술 : JavaScript (자바스크립트) / AWS / Lambda / GetFunction
- 사전) AWS Lambda 간단 설명 :
>> Aws Lambda 는 서버 리스 FaaS 솔루션으로, 함수의 인스턴스를 실행하여 이벤트를 처리할 수 있습니다.
>> Aws Lambda 는 이벤트에 응답하여 코드를 실행 하고 해당 코드에 필요한 컴퓨팅 리소스를 자동으로 관리합니다.
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
[소스 코드]
-----------------------------------------------------------------------------------------
<!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';
const accessKey = 'AK..A6';
const secretKey = 'mP..5J';
const functionName = 'device-status-manager'; // 람다 함수 명칭
// --------------------------------------------------------------------------------------------------------------
// [html 최초 로드 및 이벤트 상시 대기 실시]
window.onload = async function() {
console.log("");
console.log("=========================================");
console.log("[window onload] : [start]");
console.log("=========================================");
console.log("");
try {
// -----------------------------------------
// [AWS.config 지정]
// -----------------------------------------
AWS.config.update({
region: region,
accessKeyId: accessKey,
secretAccessKey: secretKey
});
// -----------------------------------------
// [AWS 객체 생성]
// -----------------------------------------
const aws = new AWS.Lambda();
// -----------------------------------------
// [요청 파라미터 생성]
// -----------------------------------------
const param = { // ✅ Request_파라미터
FunctionName: functionName
};
// -----------------------------------------
// [getFunction] : AWS 람다 특정 함수 정보 조회 수행
// -----------------------------------------
// AWS 참고 사이트 : https://docs.aws.amazon.com/ko_kr/lambda/latest/api/API_GetFunction.html
// -----------------------------------------
aws.getFunction( param , function(err, data) {
if (err) {
console.error("");
console.error("=========================================");
console.error("[getFunction] : [Error]");
console.error("---------------------------------------");
console.error(err);
console.error("=========================================");
console.error("");
// ---------------------------------------------
// ✅ [주요 에러 정리]
// ---------------------------------------------
// ResourceNotFoundException : 존재하지 않는 함수명/버전/에일리어스 요청 시
// ---------------------------------------------
// InvalidParameterValueException : FunctionName 형식/Qualifier가 유효하지 않은 경우 등 잘못된 파라미터
// ---------------------------------------------
// TooManyRequestsException : 호출이 과도할 때(서빙 한도 초과), 재시도(backoff) 필요
// ---------------------------------------------
// ServiceException : 내부 서비스 오류. 보통 재시도 시 복구
// ---------------------------------------------
// ---------------------------------------------
// [Body 표시 JSON]
// ---------------------------------------------
var errJson = {
response: "error",
data: err
}
// ---------------------------------------------
// ---------------------------------------------
// [에러 출력]
// ---------------------------------------------
document.write(JSON.stringify(errJson));
// ---------------------------------------------
} else {
console.log("");
console.log("=========================================");
console.log("[getFunction] : [Success]");
console.log("---------------------------------------");
console.log(JSON.stringify(data));
console.log("=========================================");
console.log("");
// ---------------------------------------------
// ✅ [로그 출력 예시 첨부]
// ---------------------------------------------
/*
{
"Code": {
"RepositoryType": "S3",
"Location": "https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/snapshots/123456789012/my-function?X-Amz-Security-Token=...",
"ImageUri": null,
"ResolvedImageUri": null,
"SourceKMSKeyArn": null
},
"Concurrency": {
"ReservedConcurrentExecutions": 100
},
"Configuration": {
"FunctionName": "my-function",
"FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
"Runtime": "nodejs18.x",
"Role": "arn:aws:iam::123456789012:role/lambda-basic-role",
"Handler": "index.handler",
"CodeSize": 304,
"Description": "Example Lambda function",
"Timeout": 3,
"MemorySize": 128,
"LastModified": "2025-11-15T07:44:53.123+0000",
"CodeSha256": "5tT2qgzYUHoqwR616pZ2dpkn/0J1FrzJmlKidWaaCgk=",
"Version": "$LATEST",
"Environment": {
"Variables": {
"ENV_TYPE": "prod",
"LOG_LEVEL": "debug"
},
"Error": null
},
"VpcConfig": {
"SubnetIds": [],
"SecurityGroupIds": [],
"VpcId": ""
},
"TracingConfig": {
"Mode": "PassThrough"
},
"RevisionId": "28f0fb31-5c5c-43d3-8955-03e76c5c1075",
"Architectures": ["x86_64"],
"EphemeralStorage": {
"Size": 512
},
"FileSystemConfigs": [],
"KMSKeyArn": null,
"PackageType": "Zip",
"ImageConfigResponse": {
"Error": null,
"ImageConfig": null
},
"Layers": [],
"MasterArn": null,
"SigningJobArn": null,
"SigningProfileVersionArn": null
}
}
*/
// ---------------------------------------------
// ---------------------------------------------
// [Body 표시 JSON]
// ---------------------------------------------
var resJson = {
response: "success",
data: data
}
// ---------------------------------------------
// ---------------------------------------------
// [결과 출력]
// ---------------------------------------------
document.write(JSON.stringify(resJson));
// ---------------------------------------------
}
});
}
catch (exception) {
console.error("");
console.error("=========================================");
console.error("[window onload] : [Exception] : 예외 상황 발생");
console.error("-----------------------------------------");
console.error(exception);
console.error("=========================================");
console.error("");
// ---------------------------------------------
// [Body 표시 JSON]
// ---------------------------------------------
var errJson = {
response: "exception",
data: exception.message
}
// ---------------------------------------------
// ---------------------------------------------
// [에러 출력]
// ---------------------------------------------
document.write(JSON.stringify(errJson));
// ---------------------------------------------
}
};
// --------------------------------------------------------------------------------------------------------------
</script>
</head>
<body>
</body>
</html>
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
[참고 사이트]
-----------------------------------------------------------------------------------------
[자바스크립트 AWS Lambda 함수 목록 리스트 조회 수행 - ListFunctions]
https://kkh0977.tistory.com/8645
https://blog.naver.com/kkh0977/224190780409
[AWS Lambda] Aws 람다 Python 3.13 기반 기본 함수 구조 설명 정리
https://kkh0977.tistory.com/8188
https://blog.naver.com/kkh0977/223962723156?trackingCode=blog_bloghome_searchlist
[AWS] [Lambda] 런타임 Python 3.13 - boto3 모듈 사용해 AWS Lambda 람다 함수 리스트 목록 조회
https://kkh0977.tistory.com/8286
https://blog.naver.com/kkh0977/224014658387?trackingCode=blog_bloghome_searchlist
[Aws Lambda] Aws 사이트에서 생성 된 Lambda 람다 검증 함수 리스트 및 내용 소스 코드 확인 방법
https://blog.naver.com/kkh0977/223765198383
[AWS] Lambda 람다 함수 수행 errorType Sandbox.Timedout 에러 발생
https://blog.naver.com/kkh0977/223962778768
-----------------------------------------------------------------------------------------
728x90
반응형
'JavaScript' 카테고리의 다른 글
Comments
