- 프로젝트 기간: 2020.08 ~ 2021.01
0.IAM (authorization and security of aws)
1.EC2 (server)
2.RDS (database)
3.S3 (storage)
4.Elastic Transcoder (video converter)
5.lambda (using automatic of video)
6.Cognito (user authorization)
Ec2 ubntu version 20.04 사용.
원래는 18.04를 사용해봤었는데 20.04 버전이 더 빠르고 안정적이라고 생각이 돼서 20.04 버전을 사용.
termius 세팅방법
(인바운드 규칙과 아웃바운드 규칙을 아래의 글에 나오는 EC2뿐 아니라 위치무관에 대해서도 허용을 해주어야 pc에서 접근이 가능하다)
EC2에서 mysql sudo apt update # MySQL 설치를 위해 업데이트
sudo apt install mysql-server # MySQL 서버 설치
sudo mysql -u root -p # MySQL 접속
(mysql -u admin -p -h bluedot-rds.cnyobjdzyehq.ap-northeast-2.rds.amazonaws.com)
elastic transcode 사용을 위해 input, output, 그리고 image 파일들을 담을 버킷 총 3개를 생성 생성할 때 객체는 모두 public으로 생성.
간단 사용법 설명 동영상 ( using console )
https://www.youtube.com/watch?v=VzAaNKBH0NE&ab_channel=SaMtheCloudGuy
어떻게 돌아가는가?
세팅법
https://jeongchul.tistory.com/581
https://jeongchul.tistory.com/582
region -> ap-northeast-1 ( japan, toyko 로 설정해야 한다. )
blog 글요약
- IAM 에서 lambda 사용자를 만든다.
- lambda 사용자에게 lambda와 s3관련 인라인 정책을 추가해준다.
- pipeline을 생성한다
- lambda를 작성한다
- lambda와 s3를 연결해준다.
참조 블로그 ( 위의 링크를 주로 참조 )
https://victorydntmd.tistory.com/341
https://jojoldu.tistory.com/31
희찬 졸업작품 sever
vsc에서 클릭하고 ctrl + D
presetId ? -->
https://docs.aws.amazon.com/ko_kr/elastictranscoder/latest/developerguide/system-presets.html ( preset )
https://docs.aws.amazon.com/ko_kr/elastictranscoder/latest/developerguide/elastictranscoder-dg.pdf
'use strict';
var AWS = require('aws-sdk');
var elasticTranscoder = new AWS.ElasticTranscoder({
region: 'ap-northeast-1'
});
exports.handler = function(event, context, callback){
var key = event.Records[0].s3.object.key;
//the input file may have spaces so replace them with '+'
var sourceKey = decodeURIComponent(key.replace(/\+/g, ' '));
//remove the extension
var outputKey = sourceKey.split('.')[0];
var params = {
PipelineId: '',
Input: {
Key: sourceKey
},
Outputs: [
{
Key: outputKey + '-1080p' + '.mp4',
PresetId: '1351620000001-000001' //Generic 1080p
,
ThumbnailPattern:'thumbnail/{count}/'+ outputKey
},
{
Key: outputKey + '-720p' + '.mp4',
PresetId: '1351620000001-000010' //Generic 720p
},
{
Key: outputKey + '-web-720p' + '.mp4',
PresetId: '1351620000001-100070' //Web Friendly 720p
// ,
// ThumbnailPattern:'thumbnail/{count}/'+ outputKey
}
]};
elasticTranscoder.createJob(params, function(error, data){
if (error){
callback(error);
}
});
};
- 유의점 -> lambda region을 toyko로 맞추어야 한다. 현재 aws 계정에 region이 seoul로 돼있는 곳에 코드 써봤자 안먹음.
- thumbnailPattern에서 오류가 나면 변환이 안되고 멈춰버림 ( thumbnail pattern으로 변환하는 것은 맞음. 변환하는 것 확인 )
- ThumbnailPattern:'thumbnail/{count}/'+ outputKey -> outputkey로 주고 싶으면, 앞에 슬래시를 하나 넣어주어야 한다.
- 변환된 파일을 동기적으로 파일이 담길때까지 기다렸다가 반환하기