AWS Amplify
๐งญ Hitchhikers - AWS Architecture
๐ 1. ํต์ฌ ๊ธฐ๋ฅ ์์ฝ
์ฑ ๊ธฐ๋ฅ:
- ํ์๊ฐ์ / ๋ก๊ทธ์ธ (์ธ์ฆ)
- ์ผ์ ๋ฑ๋ก / ๋ณด๊ธฐ
- ์ฌ์ฉ์ ํ๋กํ
- ์ ์ ๋ฆฌ์คํธ ๊ด๋ฆฌ
- ๋งต ์ฐ๋
- ์๋ฆผ ๊ธฐ๋ฅ
๐ 2. ์ฌ์ฉํ๋ AWS ์๋น์ค (Amplify ๊ธฐ๋ฐ)
๊ธฐ๋ฅ | AWS์๋น์ค | Amplify๋ชจ๋ |
---|---|---|
์ธ์ฆ | Cognito | amplify add auth |
๋ฐ์ดํฐ์ ์ฅ | DynamoDB | amplify add storage |
๋ฐฑ์๋๋ก์ง | Lambda | amplify add function |
API ์ฐ๋ | API gateway | amplify add api |
์ง๋ ๊ธฐ๋ฅ | AWS Location Service + MapLibre | amplify add geo |
ํ์ผ ์ ๋ก๋ | S3 | amplify add storage |
ํธ์คํ | Amplify hosting | amplify add hosting |
๐ 3. ์ธ์ฆ: Amplify + Cognito
โ ๊ตฌํ ๋ฐฉ๋ฒ
amplify add auth
โข ์ด๋ฉ์ผ ๊ธฐ๋ฐ ํ์๊ฐ์ / ๋ก๊ทธ์ธ
โข Cognito User Pool ์๋ ์์ฑ
โข ํ๋ก ํธ์๋์ Auth ๋ชจ๋๋ก ๋ฐ๋ก ์ฐ๋ ๊ฐ๋ฅ
โ ํ๋ก ํธ ์ฝ๋ ์์
1
2
3
4
5
6
7
8
9
import { Auth } from 'aws-amplify';
await Auth.signUp({
username: 'gsl@example.com',
password: 'Password123!',
attributes: { email: 'gsl@example.com' }
});
await Auth.signIn('gsl@example.com', 'Password123!');
โ ์ ์ ๊ด๋ฆฌ๋ ์ด๋์?
โข AWS Cognito ์ฝ์ (๋๋ Admin API)์์ ์ ์ ์กฐํ/์ญ์ /๊ทธ๋ฃน ๊ด๋ฆฌ
๐ ๏ธ 4. ์ผ์ ๋ฑ๋ก/์ ์ ๋ฐ์ดํฐ ์ฒ๋ฆฌ: Lambda + DynamoDB ์ฐ๋
โ ์ ์ฒด ํ๋ฆ
1
2
3
4
5
6
7
React/Vue App
โ
API Gateway (REST)
โ
Lambda Function
โ
DynamoDB
โ Step-by-step ๊ตฌ์ฑ
๐ 1) Lambda ํจ์ ์ถ๊ฐ
amplify add function
โข ์: createScheduleFn
โข Node.js ๊ธฐ๋ฐ Lambda ์์ฑ
โข DynamoDB ์ ๊ทผ ๊ถํ ๋ถ์ฌ (Yes)
๐ 2) DynamoDB ํ ์ด๋ธ ์์ฑ
amplify add storage
โข NoSQL (DynamoDB) ์ ํ
โข ์: ScheduleTable
โข Partition Key: scheduleId
โข IAM ๊ถํ ์ค์ (Lambda์์ ์ฝ๊ธฐ/์ฐ๊ธฐ ํ์ฉ)
๐ 3) Lambda ์ฝ๋ ์์
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient();
exports.handler = async (event) => {
const data = JSON.parse(event.body);
const params = {
TableName: process.env.STORAGE_SCHEDULETABLE_NAME,
Item: {
scheduleId: data.scheduleId,
userId: data.userId,
title: data.title,
date: data.date,
},
};
await docClient.put(params).promise();
return {
statusCode: 200,
body: JSON.stringify({ message: 'Saved!' }),
};
};
โ ๏ธ ํ๊ฒฝ๋ณ์ STORAGE_SCHEDULETABLE_NAME๋ Amplify๊ฐ ์๋ ์ค์
๐ 4) API Gateway ์ฐ๊ฒฐ
amplify add api
- REST API ์ ํ
- Lambda ์ฐ๋ : createSchedulefn
- ์ํธ๋ฆฌํฌ์ธํธ : /schedule
๐ 5. ํ๋ก ํธ์๋์์ API ํธ์ถ
1
2
3
4
5
6
7
8
9
10
import { API } from 'aws-amplify';
await API.post('scheduleAPI', '/schedule', {
body: {
scheduleId: '001',
userId: 'gunsoo',
title: 'Ride to Toronto',
date: '2025-04-10'
}
});
๐ฆ 6. ์ถ๊ฐ ๊ธฐ๋ฅ ์ ์ ๋ฐ ์ฐ๋ ๋ฐฉ๋ฒ
๊ธฐ๋ฅ | ์๋น์ค | ๊ตฌ์ฑ๋ฐฉ๋ฒ |
---|---|---|
ํ๋กํ ์ฌ์ง ์ ๋ก๋ | s3 | amplify add storage (Content) + Storage.put() ์ฌ์ฉ |
์ง๋ ์ฐ๋ | AWS Location Service | amplify add geo + MapLibre JS ์ฐ๋ |
ํธ์ ์๋ฆผ | SNS ๋๋ FCM | Lambda + Firebase Admin SDK or SNS trigger |
๊ถํ ๊ตฌ๋ถ | Cognito ๊ทธ๋ฃน | amplify update auth โ ๊ทธ๋ฃน ์์ฑ โ ์ ์ ์ญํ ๋ถ๋ฆฌ |
๐ 7. ๋ฐฐํฌ ๋ฐ ๊ด๋ฆฌ
์ ์ฒด ๋ฆฌ์์ค ๋ฐฐํฌ:
amplify push
์ฝ๋ + ์ธํ๋ผ ๋ชจ๋ Git์ผ๋ก ๋ฒ์ ๊ด๋ฆฌ ๊ฐ๋ฅ
โข /amplify/backend/ ์๋์ CloudFormation ๊ธฐ๋ฐ ์ค์ ์๋ ์ ์ฅ (IaC)
โ ์ต์ข ๊ตฌ์กฐ ์ ๋ฆฌ (๋์)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[React / Vue ์ฑ]
โ
Amplify API (REST)
โ
Lambda Function (๋ฐฑ์๋ ๋ก์ง)
โ
DynamoDB (๋ฐ์ดํฐ ์ ์ฅ)
[Amplify Auth]
โณ Cognito (์ ์ ์ธ์ฆ / ๊ทธ๋ฃน ๊ด๋ฆฌ)
[Amplify Storage]
โณ S3 (ํ์ผ ์
๋ก๋)
โณ DynamoDB (NoSQL ์ ์ฅ์)
[์ง๋ ์ฐ๋]
โณ AWS Location Service (Geo)
[CI/CD]
โณ Amplify Hosting + GitHub ์ฐ๋
๐ ๊ฒฐ๋ก
Gunsoo๋์ Hitchhikers ์ฑ์ AWS Amplify๋ฅผ ์ฌ์ฉํ๋ฉด,
โ ์ธ์ฆ๋ถํฐ
โ ์๋ฒ๋ฆฌ์ค ๋ฐฑ์๋
โ ์ค์๊ฐ ๋ฐ์ดํฐ ์ ์ฅ
โ ํ์ผ ๊ด๋ฆฌ
โ ์ง๋ ๊ธฐ๋ฅ