Deploy JS SPA app to AWS
Deploy a SPA JS app to AWS automatically with stack: GitHub, CodePipeline,
CodeBuild, CloudFront, S3 and Route53
1. Create S3 bucket
- Create new bucket with name as same as domain: Eg:
kuadx.lookatmedam.jp
- Update Bucket Policy
1 | { |
- Properties —> Static website hosting —> Use this bucket to host a website
1 | Index document: index.html |
2. CodeBuild
- Add
buildspec.yml
1 | version : 0.2 |
- Create CodeBuild project
- Vào IAM —> Create Policy - name: s3_kuadx.lookatmedam.jp
1 | { |
- Attach Policy này vào Role
codebuild-lookatme-kuadx
- Try build —> Succeed rồi thì tiếp.
3. Code Pipeline
Skip deploy stage as it’ve been done in CodeBuild
—> Succeed rồi thì thử cái domain static website hosting ở trong S3 xem lên chưa.
4. CloudFront
Create Distribution —> Web
1 | Origin Domain Name : Domain S3 Static Web Hosting |
Chờ một lúc cho Distribution nó chuyển thành Deployed
5. Route 53
Vào Route53 —> Hosted Zones —> Chọn domain —> Create new record set