728x90

기본적인 요청-응답(클라이언트-서버) 메시지 교환 패턴 (P5)

 

하나의 단계(tier)는 특정 책임을 갖는 복수의 계층(layer)을 갖는다.

 

서버리스 아키텍처에는 전통적인 백엔드 시스템이 존재하지 않음 

서버리스 아키텍처의 원칙 (P9)

  1. 컴퓨팅 서비스를 사용해 요구에 맞게 코드를 실행한다. (서버없이)

  2. 단일 목적의 상태 없는 함수를 작성한다. 

  3. 푸시 기반, 이벤트 주도 파이프라인을 설계한다. 

  4. 더 두텁고 강한 프론트엔드를 만든다. ⇒ React, Angular, Vue, ...

  5. 서드파티 서비스를 받아들인다. ⇒ 예) 소셜 로그인






서버리스 아키텍처 사례: 클라우드 그루 (P25)



목표 시스템 구성 (P46)

 




개발 환경 구성

#1 AWS CLI 설치 확인

PS C:\Users\i> aws --version

aws-cli/2.1.27 Python/3.7.9 Windows/10 exe/AMD64 prompt/off

 

설치가 필요한 사람은 아래 URL 참조

https://docs.aws.amazon.com/ko_kr/cli/latest/userguide/install-cliv2.html

 

#2 node.js 설치 확인

PS C:\Users\i> node --version

v14.15.4

PS C:\Users\i> npm --version

6.14.10

 

설치가 필요한 사람은 아래 URL 참조

https://nodejs.org/ko/



#3 IAM에 사용자 생성 (P322)

 



#4 CLI 환경에서 작업할 수 있도록 액세스 키 ID, 비밀 엑세스 키, 리전 정보를 설정

PS C:\Users\i> aws configure

AWS Access Key ID [****************3EGR]: AKIAS4**********4OWB

AWS Secret Access Key [****************9fk/]: d91uKydp/9***************rLI8zSPBXaZtVx2

Default region name [us-east-1]: us-east-1                   ⇐ 버지니아 북부 

Default output format [None]:



#5 사용자 권한 설정



 

 

#6 S3 버킷 생성 (P326)

동영상을 업로드할 버킷과 Elastic Transcoder로 트랜스코딩된 동영상을 저장할 버킷을 각각 생성

~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

 




#7 IAM 역할 생성 (P327)

Lambda 함수가 S3 버킷 및 Elastic Transcoder와 상호작용할 수 있도록 역할을 부여

 

 

AWSLambdaExecute ⇒ Lambda 함수가 S3 및 CloudWatch와 상호작용 가능

 

AmazonElasticTranscoder_JobsSubmitter ⇒ Lambda 함수가 Elastic Transcoder에 새로운 트랜스코딩 작업을 전달 가능

 




Elastic Transcoder에 부여할 역할을 생성

 

 

 







#8 람다 함수 생성 (P328)

업로드 버킷(serverless-video-upload-*)에 파일이 추가되면 Elastic Transcoder 작업을 시작하는 함수

 

 



#9 Elastic Transcoder 구성 (P329)

다양한 형식과 비트 전송률로 비디오 트랜스코딩을 수행하기 위한 파이프 라인을 설정 ⇒ 업로드한 동영상의 포맷을 일관된 포맷으로 변경

 

 

 

 



#10 npm 구성 (P330)

npm(node package manager) 기반 AWS 환경을 위한 테스트, 패키징, 배포 과정을 자동화

 

PS C:\Users\i> cd \

PS C:\> mkdir serverless

PS C:\> cd serverless

PS C:\serverless> mkdir transcode-video

PS C:\serverless> cd transcode-video

PS C:\serverless\transcode-video> npm init

This utility will walk you through creating a package.json file.

It only covers the most common items, and tries to guess sensible defaults.

 

See `npm help init` for definitive documentation on these fields

and exactly what they do.

 

Use `npm install <pkg>` afterwards to install a package and

save it as a dependency in the package.json file.

 

Press ^C at any time to quit.

package name: (transcode-video) [엔터]

version: (1.0.0) [엔터]

description: [엔터]

entry point: (index.js) [엔터]

test command: [엔터]

git repository: [엔터]

keywords: [엔터]

author: [엔터]

license: (ISC) [엔터]

About to write to C:\serverless\transcode-video\package.json:

 

{

  "name": "transcode-video",

  "version": "1.0.0",

  "description": "",

  "main": "index.js",

  "scripts": {

    "test": "echo \"Error: no test specified\" && exit 1"

  },

  "author": "",

  "license": "ISC"

}



Is this OK? (yes) [엔터]

 

PS C:\serverless\transcode-video> type .\package.json    ⇐ npm init 명령을 통해 

{                                                                                               package.json 파일이 생성된 것을 확인

  "name": "transcode-video",

  "version": "1.0.0",

  "description": "",

  "main": "index.js",

  "scripts": {

    "test": "echo \"Error: no test specified\" && exit 1"

  },

  "author": "",

  "license": "ISC"

}

 

PS C:\serverless\transcode-video> npm install aws-sdk     ⇐ node.js 기반의 AWS SDK 모듈을 설치

npm notice created a lockfile as package-lock.json. You should commit this file.

npm WARN transcode-video@1.0.0 No description

npm WARN transcode-video@1.0.0 No repository field.

 

+ aws-sdk@2.861.0

added 14 packages from 66 contributors and audited 14 packages in 10.865s

 

1 package is looking for funding

  run `npm fund` for details

 

found 0 vulnerabilities

 

PS C:\serverless\transcode-video> type .\package.json      ⇐ AWS SDK 모듈 dependence 추가를 확인

{

  "name": "transcode-video",

  "version": "1.0.0",

  "description": "",

  "main": "index.js",

  "scripts": {

    "test": "echo \"Error: no test specified\" && exit 1"

  },

  "author": "",

  "license": "ISC",

  "dependencies": {

    "aws-sdk": "^2.861.0"

  }

}



#11 windows 용 zip 설치

앞에서 다운로드 및 압축해제한 zip 디렉터리와 PATH 환경변수는 삭제해 주세요.

#11-1 zip.exe 다운로드 후 C:\Windows\System32 디렉터리 아래로 복사

http://stahlworks.com/dev/zip.exe

 

#11-2 Windows PowerShell을 새로 실행한 후 zip 명령어 실행 여부를 확인

PS C:\Users\i> zip

Copyright (c) 1990-2006 Info-ZIP - Type 'zip "-L"' for software license.

Zip 2.32 (June 19th 2006). Usage:

zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]

  The default action is to add or replace zipfile entries from list, which

  can include the special name - to compress standard input.

  If zipfile and list are omitted, zip compresses stdin to stdout.

  -f   freshen: only changed files  -u   update: only changed or new files

  -d   delete entries in zipfile    -m   move into zipfile (delete files)

  -r   recurse into directories     -j   junk (don't record) directory names

  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)

  -1   compress faster              -9   compress better

  -q   quiet operation              -v   verbose operation/print version info

  -c   add one-line comments        -z   add zipfile comment

  -@   read names from stdin        -o   make zipfile as old as latest entry

  -x   exclude the following names  -i   include only the following names

  -F   fix zipfile (-FF try harder) -D   do not add directory entries

  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)

  -T   test zipfile integrity       -X   eXclude eXtra file attributes

  -!   use privileges (if granted) to obtain all aspects of WinNT security

  -R   PKZIP recursion (see manual)

  -$   include volume label         -S   include system and hidden files

  -e   encrypt                      -n   don't compress these suffixes





JavaScript

JavaScript 학습 ⇒ https://www.w3schools.com/js/DEFAULT.asp

JavaScript 함수를 정의하는 방법

  • 함수 선언문 (function statement)

  • 함수 표현식 (function expression)

  • Function() 생성자 함수

 

함수 선언문 방식으로 함수를 생성

// 함수 선언문

function add (x , y) { return x + y; }

~~~~~~~~ ~~~ ~~~~~~~ ~~~~~~~~~~~~~~~~~

키워드   이름   |    함수 본문

                      +-- 인자, 매개변수, 파라미터    

 

// 함수 호출

var val = add(3, 4);

console.log(val); // 3 + 4의 결과를 출력



함수 표현식 방식으로 함수를 생성 ⇒ 함수 리터럴로 함수를 만들고, 생성된 함수를 변수에 할당

JavaScript에서는 함수도 하나의 값으로 취급

var x = 1; // x라는 변수에 1을 할당

var y = 2; // y라는 변수에 2를 할당

var add = function (x, y) { // add라는 변수에 "매개변수로 전달된 두 수를 더한 값을 반환하는 익명함수"를 할당

return x + y;

};

 

var z = x;

var sum = add; // 변수처럼 다른 변수에 재할당

 

console.log(x);

console.log(add(3, 4)); // 7

 

console.log(z);

console.log(sum(3, 4)); // 7



함수 표현식

  • 익명 함수 표현식

  • 기명 함수 표현식

    • 함수 표현식에서 사용된 함수 이름은 외부 코드에서 접근이 불가능 ⇒ #1

    • 함수 내부에서 해당 함수를 재귀적으로 호출할 때 또는 디버깅할 때 사용 ⇒ #2

 

var add = function sum (x, y) { return x, y; }

 

// #1

console.log(add(3, 4)); // 7

console.log(sum(3, 4)); // sum is not defined

 

// #2

var myfactorial = function factorial(n) {

    if (n <= 1) return 1;

    return n * factorial(n - 1);

}

 

console.log(myfactorial(5)); // 120

console.log(factorial(5)); // factorial is not defined



함수 선언문에서 정의한 함수는 외부에서 호출이 가능하도록, 자바스크립트 엔진에 의해서 함수 이름과 함수 변수 이름이 동일한 기명 함수 표현식으로 변경

function add(x, y) { return x + y; }

var add = function add(x, y) { return x + y; }

      ~~~                   ~~~

    함수변수이름  함수이름



Function() 생성자 함수를 이용한 함수 생성

Function() 기본 내장 생성자 함수 ⇒ https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Function

 

함수 선언문, 함수 표현식 방식도 내부적으로는 Function() 생성자 함수를 이용해서 생성

 

new Function ([arg1[, arg2[, ...argN]],] functionBody)

 

var add = new Function('x', 'y', 'return x + y');

console.log(add(3, 4)); // 7 



함수 호이스팅(function hosting)

함수 선언문 형태로 정의한 함수는 함수의 유효 범위가 코드의 맨 처음부터 시작

⇒ 함수를 정의한 위치와 관계 없이 호출이 가능

 

console.log(add(1, 2)); // 3 ⇐ 

 

function add(x, y) { // var add = function add(x, y) { return x + y; };

    return x + y;

}

 

console.log(add(3, 4)); // 7

 

함수 호이스팅이 발생하는 원인(이유)

⇒ JavaScript의 변수 생성(instantiation)과 초기화(initialization) 작업이 분리되어 진행되기 때문



함수 표현식 방식에서는 함수 호이스팅이 발생하지 않는다.

console.log(x);     // undefined

 

var x = 2;

console.log(x);     // 2

 

// console.log(y);     // y is not defined

 

var z;

console.log(z);     // undefined

 

// console.log(add(1, 2)); // add is not defined -> add is not a function

 

var add = function(x, y) { 

    return x + y;

};

 

console.log(add(3, 4)); // 7



함수 종류

콜백 함수(callback function)

개발자가 명시적으로 코드를 통해 호출하는 함수가 아니고, 

개발자는 함수를 등록만 하고, 이벤트가 발생했을 때 또는 특정 시점에 도달했을 때 시스템에서 호출하는 호출

 

특정 함수의 인자로 넘겨서 코드 내부에서 호출되는 함수 



즉시 실행 함수(immediate function)

함수를 정의함과 동시에 바로 실행하는 함수

최초 한번의 실행만을 필요로하는 초기화 구문에 사용

 

function add(x, y) {

    console.log(x + y);

}

add(3, 4); // 함수 선언문 형식으로 정의한 함수는 호출을 통해서 실행

 

(function add(x, y) {            ⇒ 함수 리터럴을 괄호로 둘러싸고

    console.log(x + y);

})(3, 4);                               ⇒ 함수 실행에 필요한 인자를 전달

 

(function add(x, y) {

    console.log(x + y);

}(3, 4));



(function (x, y) {            // 일반적으로 즉시 실행 함수는 한번만 호출되므로 익명 함수로 구현

    console.log(x + y);

})(3, 4);

(function (x, y) {

    console.log(x + y);

}(3, 4));



// jQuery 

(function() { 

$(document).ready(function() {

...

});

}());



함수를 반환하는 함수

var self = function() {

    console.log("a");

    return function() {

        console.log("b");

    };

};

 

self();                     // a

console.log("---------");

self = self();              // a

self();                     // b



내부 함수(inner function)

function parent() {

    var a = 100;

    var b = 200;

    function child() {

        var b = 300;

        console.log(a, b);  // 100, 300          ⇐ 부모 함수의 변수를 사용

    }

 

    child();

}

 

parent();

child();        // child is not defined             ⇐ 외부 직접 호출할 수 없도록 차단

console.log(a); // a is not defined



함수 외부에서 내부 함수를 사용할 경우 ⇒ 내부 함수를 반환

function parent() {

    var a = 100;

    var b = 200;

 

    return function child() {

        var b = 300;

        console.log(a, b);  // 100, 300

    }

}

 

var inner = parent();

inner();





첫번째 람다 함수 코드를 작성 (P50)



#1 VSC 실행 > Open Folder > C:\serverless\transcode-video 선택 > New File > index.js 파일 생성

 



// P51

'use strict';

var AWS = require('aws-sdk');


var elasticTranscoder = new AWS.ElasticTranscoder({

    region: 'us-east-1'

});


exports.handler = function(event, context, callback) {

    console.log('Welcome');

 

    // https://docs.aws.amazon.com/ko_kr/lambda/latest/dg/with-s3.html

    // S3 버킷에 저장된 파일명(=객체명)을 가져옴

    var key = event.Records[0].s3.object.key;   

    // 파일 이름에서 "+" 기호를 " " 문자로 대체하고 URL 디코딩

    // ==> URL 인코딩되었던 파일명을 원본 형태로 변경

    var sourceKey = decodeURIComponent(key.replace(/\+/g, ' '));

    // 확장자를 제거 ==> 파일의 이름 부분만 추출 

    var outputKey = sourceKey.split('.')[0];

    // Elastic Transcoder의 파이프라인에 전달하는 값(인자)

    var params = {

        PipelineId: '1615428499293-vsxsm4',     // 본인의 것으로 변경

        Input: {

            Key: sourceKey                      // S3 버킷의 객체명(파일명)

        },

        Outputs: [

            {

                // 트랜스코딩된 결과 파일명 ==> 원본파일이름/원본파일이름-프리셋.mp4

                Key: outputKey + '/' + outputKey + '-1080p' + '.mp4', 

                // 미리 정의되어 있는 동영상 포맷

                // https://docs.aws.amazon.com/ko_kr/elastictranscoder/latest/developerguide/system-presets.html

                // 일반 1080p

                PresetId: '1351620000001-000001' 

            },

            {

                Key: outputKey + '/' + outputKey + '-720p' + '.mp4',

                // 일반 720p

                PresetId: '1351620000001-000010' 

            },

            {

                Key: outputKey + '/' + outputKey + '-web-720p' + '.mp4',

                // 웹: Facebook, SmugMug, Vimeo, YouTube

                PresetId: '1351620000001-100070' 

            }

        ]};

 

    //                          인자  , 트랜스코딩이 끝났을 때 호출할 콜백 함수

    elasticTranscoder.createJob(params, function(error, data) {

        if (error) {

            // 트랜스코딩 과정에서 오류가 발생하면 핸들러 함수를 호출한 곳으로 오류를 반환

            callback(error);

        }

    });

};






#2 로컬 테스트

run-local-lambda 모듈을 사용해서 람다 함수를 로컬에서 실행

 

#2-1 run-local-lambda 모듈 설치

PS C:\serverless\transcode-video> npm install run-local-lambda --save-dev

npm WARN transcode-video@1.0.0 No description

npm WARN transcode-video@1.0.0 No repository field.

 

+ run-local-lambda@1.1.1

added 1 package from 1 contributor and audited 15 packages in 2.44s

 

1 package is looking for funding

  run `npm fund` for details

 

found 0 vulnerabilities



#2-2 테스트에 사용할 데이터를 생성

c:\serverless\transcode-video\tests\event.json

{

    "Records": [

      {

        "eventVersion": "2.1",

        "eventSource": "aws:s3",

        "awsRegion": "us-east-2",

        "eventTime": "2019-09-03T19:37:27.192Z",

        "eventName": "ObjectCreated:Put",

        "userIdentity": {

          "principalId": "AWS:AIDAINPONIXQXHT3IKHL2"

        },

        "requestParameters": {

          "sourceIPAddress": "205.255.255.255"

        },

        "responseElements": {

          "x-amz-request-id": "D82B88E5F771F645",

          "x-amz-id-2": "vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo="

        },

        "s3": {

          "s3SchemaVersion": "1.0",

          "configurationId": "828aa6fc-f7b5-4305-8584-487c791949c1",

          "bucket": {

            "name": "lambda-artifacts-deafc19498e3f2df",

            "ownerIdentity": {

              "principalId": "A3I5XTEXAMAI3E"

            },

            "arn": "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df"

          },

          "object": {

            "key": "my+video.mp4",

            "size": 1305107,

            "eTag": "b21b84d653bb07b05b1e6b33684dc11b",

            "sequencer": "0C0F6F405D6ED209E1"

          }

        }

      }

    ]

  }

 

#2-3 테스트 스크립트 추가

c:\serverless\transcode-video\package.json

{

  "name": "transcode-video",

  "version": "1.0.0",

  "description": "",

  "main": "index.js",

  "scripts": {

    "test": "run-local-lambda --file index.js --event tests/event.json"

  },

  "author": "",

  "license": "ISC",

  "dependencies": {

    "aws-sdk": "^2.861.0"

  },

  "devDependencies": {

    "run-local-lambda": "^1.1.1"

  }

}

 

#2-4 테스트를 실행

PS C:\serverless\transcode-video> npm test

 

> transcode-video@1.0.0 test C:\serverless\transcode-video

> run-local-lambda --file index.js --event tests/event.json

 

Welcome

{

  errorMessage: 'User: arn:aws:iam::199503606661:user/lambda-upload is not authorized to perform: elastictranscoder:CreateJob on resource: ⇐ 권한 오류 발생

arn:aws:elastictranscoder:us-east-1:199503606661:pipeline/1615428499293-vsxsm4',

  errorType: 'AccessDeniedException',

  stack: 'AccessDeniedException: User: arn:aws:iam::199503606661:user/lambda-upload is not authorized to perform: elastictranscoder:CreateJob on resource: arn:aws:elastictranscoder:us-east-1:199503606661:pipeline/1615428499293-vsxsm4\n' +

    '    at Object.extractError (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\protocol\\json.js:52:27)\n' +

    '    at Request.extractError (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\protocol\\rest_json.js:55:8)\n' +

    '    at Request.callListeners (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\sequential_executor.js:106:20)\n' +

    '    at Request.emit (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\sequential_executor.js:78:10)\n' +

    '    at Request.emit (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\request.js:688:14)\n' +

    '    at Request.transition (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\request.js:22:10)\n' +

    '    at AcceptorStateMachine.runTo (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\state_machine.js:14:12)\n' +

    '    at C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\state_machine.js:26:10\n' +

    '    at Request.<anonymous> (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\request.js:38:9)\n' +

    '    at Request.<anonymous> (C:\\serverless\\transcode-video\\node_modules\\aws-sdk\\lib\\request.js:690:12)'

}



#3 람다 함수를 배포

#3-1 사전 배포 및 배포 스크립트를 추가

사전 배포 ⇒ 배포 전에 수행해야 할 작업 ⇒ 소스 코드를 하나의 zip 파일로 압축

 

c:\serverless\transcode-video\package.json

{

  "name": "transcode-video",

  "version": "1.0.0",

  "description": "",

  "main": "index.js",

  "scripts": {

    "test": "run-local-lambda --file index.js --event tests/event.json"

    "predeploy": "del Lambda-Deployment.zip & zip -r Lambda-Deployment.zip * -x *.zip *.log node_modules/aws-sdk/* node_modules/run-local-lambda/* tests/*", 

    "deploy": "aws lambda update-function-code --function-name 람다함수ARN --zip-file fileb://Lambda-Deployment.zip"

  },

  "author": "",

  "license": "ISC",

  "dependencies": {

    "aws-sdk": "^2.861.0"

  },

  "devDependencies": {

    "run-local-lambda": "^1.1.1"

  }

}



zip -r Lambda-Deployment.zip * -x *.zip *.log node_modules/aws-sdk/* node_modules/run-local-lambda/* tests/*

       ~~ ~~~~~~~~~~~~~~~~~~~~~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      |   압축 파일명                       |   압축 제외

      +-- 하위 디렉터리를 포함      |

                                                  +-- 압축 대상 → 모두(전체)

 

aws lambda update-function-code --function-name 람다함수ARN --zip-file fileb://Lambda-Deployment.zip

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

aws cli 명령어                                           람다 함수 이름                                 소스 코드를 포함한 배포 파일

 



#3-2 배포 실행

PS C:\serverless\transcode-video> npm run deploy

 

> transcode-video@1.0.0 predeploy C:\serverless\transcode-video

> zip -r Lambda-Deployment.zip * -x *.zip *.log

 

  adding: index.js (172 bytes security) (deflated 53%)

  adding: node_modules/ (192 bytes security) (stored 0%)

:

  adding: node_modules/xmlbuilder/README.md (172 bytes security) (deflated 62%)

  adding: package-lock.json (172 bytes security) (deflated 65%)

  adding: package.json (172 bytes security) (deflated 48%)

 

> transcode-video@1.0.0 deploy C:\serverless\transcode-video

> aws lambda update-function-code --function-name arn:aws:lambda:us-east-1:199503606661:function:transcode-videom --zip-file fileb://Lambda-Deployment.zip

 

{

    "FunctionName": "transcode-videom",

    "FunctionArn": "arn:aws:lambda:us-east-1:199503606661:function:transcode-videom",

    "Runtime": "nodejs12.x",

    "Role": "arn:aws:iam::199503606661:role/lambda-s3-execution-role",

    "Handler": "index.handler",

    "CodeSize": 8511963,

    "Description": "",

    "Timeout": 3,

    "LastModified": "2021-03-11T06:44:55.428+0000",

    "CodeSha256": "njDNlfDyqYbmTt0r1WVtIRnZWGiXw9K7lPWkvnHFdrE=",

    "Version": "$LATEST",

    "TracingConfig": {

        "Mode": "PassThrough"

    },

    "RevisionId": "492e3c21-473b-465f-ab04-0d4f6f6bdc47",

    "State": "Active",

    "LastUpdateStatus": "Successful",

    "PackageType": "Zip"

}

 



#4 S3를 람다 함수에 연결

파일을 업로드 버킷에 추가할 때 마다 이벤트를 발생시켜 람다 함수가 호출되도록 구성

 



 



#5 람다 콘솔에서 람다 함수 테스트 



#6 업로드 버킷에 동영상 파일을 업로드

주의: 작은 크기의 동영상 파일을 업로드해야 함

https://file-examples.com/index.php/sample-video-files/sample-avi-files-download/




 



CloudWatch에서 로그를 확인



트랜스코딩된 결과를 저장하는 S3 버킷을 확인

 

 

SNS 구성 (P61)

 

트랜스 코딩된 파일이 저장되는 S3 버킷과 SNS 서비스를 연동

                                        ~~~~~~~~~~ ⇒ fadeout

  1. 관리자(사용자)에게 이메일을 전송

  2. 트랜스 코딩된 파일을 외부에서 사용할 수 있도록 권한을 변경하는 람다 함수를 호출

  3. 트랜스 코딩된 파일들의 메타 데이터를 생성하는 람다 함수를 호출



#1 SNS 주제를 생성

 

 

#2 SNS 보안 정책을 수정

트랜스 코딩된 파일이 버킷에 추가될 때 SNS 서비스를 호출할 수 있도록 보안 정책을 수정

 

 

 

#3 S3를 SNS에 연결





#4 SNS 주제에 이메일 구독을 생성

 

 

 

#5 테스트

#5-1 업로드 버킷의 파일명을 변경



#5-2 transcode-video 람다 함수의 로그를 확인



#5-3 트랜스 코딩된 파일들이 생성되었는지 S3 버킷을 확인

 

#5-4 이메일 통지를 확인

 









지금까지 한 내용 (P50~65)




































728x90

'CLOUD > AWS' 카테고리의 다른 글

3/15 - AWS 12차시  (0) 2021.03.15
3/12 - AWS 11차시  (0) 2021.03.12
3/10 - AWS 9차시  (0) 2021.03.10
3/9 - AWS 8차시  (0) 2021.03.09
3/8 - AWS 7차시  (0) 2021.03.08

+ Recent posts