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.

  1. Tải source code của sam project dưới đây
  • fcjdmssam.zip (2366 ko)
    1. 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
    1. Mở bảng điều khiển của CloudFormation
    2. Chọn Stacks ở menu phía bên trái và chọn stack bạn mới tạo.

    CreateRepository

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

    CreateRepository

    1. 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
    
    1. 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

    CreateRepository

    1. 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)`
    1. 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)
    1. 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)
    1. Chạy câu lệnh amplify push để cập nhật các resource trên cloud.

    2. 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.