Chuẩn bị
Trước khi thực hiện nội dung chính của workshop này, chúng ta chuẩn bị các dịch vụ và dữ liệu cho ứng dụng.
- Tải source code của sam project dưới đây
fcjdmssam.zip
(2366 ko)
- Chạy câu lệnh dưới đây để triển khai sam
sam build
sam deploy --guided
- Nhập nội dung như sau:
- Stack Name []:
fcjdmssam
- AWS Region []:
ap-southeast-1
- Confirm changes before deploy [Y/n]:
y
- Allow SAM CLI IAM role creation [Y/n]:
y
- Disable rollback [y/N]:
n
- DocsList may not have authorization defined, Is this okay? [y/N]:
y
- DocsUpload may not have authorization defined, Is this okay? [y/N]:
y
- DocsDelete may not have authorization defined, Is this okay? [y/N]:
y
- GeneralInforUpload may not have authorization defined, Is this okay? [y/N]:
y
- GeneralInforGet may not have authorization defined, Is this okay? [y/N]:
y
- Save arguments to configuration file [Y/n]:
y
- Mở bảng điều khiển của CloudFormation
- Chọn Stacks ở menu phía bên trái và chọn stack bạn mới tạo.

- Chọn tab Outputs, ghi lại API URL

- Nếu bạn chưa tải source code của ứng dụng, chạy các câu lệnh sau:
git clone https://github.com/AWS-First-Cloud-Journey/FCJ-Serverless-DMS.git
cd FCJ-Serverless-DMS
npm install
- Mở tệp src/constant.js và thay thế giá trị của APP_API_URL với URL bạn vừa ghi lại

- Chạy câu lệnh
amplify init
để khởi tạo một dự án Amplify mới. Chọn câu trả lời như dưới đây:
- Enter a name for the project (
FCJServerlessDMS
)
- Initialize the project with the above configuration? (Y/n) (
Yes
)
- Select the authentication method you want to use: (AWS profile)
- Please choose the profile you want to use (default)
- Help improve Amplify CLI by sharing non sensitive configurations on failures (y/N) (N)`
- Chạy câu lệnh
amplify import auth
để import tài nguyên Amazon Cognito mà chúng ta đã tạo vào project. Chọn câu trả lời như dưới đây:
- What type of auth resource do you want to import? · (Cognito User Pool and Identity Pool)
- Select the User Pool you want to import: (cognito-fcj-dms)
- Chạy câu lệnh
amplify import storage
để import bucket chúng ta đã tạo vào project. Chọn câu trả lời như dưới đây:
- Select from one of the below mentioned services: (S3 bucket - Content (Images, audio, video, etc.))
- Select the S3 Bucket you want to import: · (fcjdmsstore)
-
Chạy câu lệnh amplify push
để cập nhật các resource trên cloud.
-
Chạy câu lệnh sau để build và tải thư mục build lên S3 bucket:
yarn build
aws s3 cp build s3://fcjdmswebstore --recursive
Chúng ta đã chuẩn bị xong source cần thiết cho các bước tiếp theo.