1. install aws
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
aws — version
aws-cli/2.1.21 Python/3.7.4 Darwin/20.2.0 exe/x86_64 prompt/off
2. Add admin user to Identity and Access Management (IAM)
AWS CLI commands will be run under a specific user with desired permissions. If you already have an admin user, you can skip this step.
In AWS console, go to IAM service
In left menu, go to Access management => Users
In right main window, click on blue “Add user” button
Type in user name, check “Programmatic access” checkbox and click blue “next” button
Click “Attach existing policies” and check “AdministratorAccess” and click blue “next” button
Tags are optional, click blue “next” button
Finally, click blue “Create user” button
Download .CSV file. (Store in safe place. This file will have your access id and access key. Once you leave this page, AWS console will not show this information again)
3. Configure AWS CLI
In terminal, run the following command:
aws configure
Enter access id
Enter access key
Enter default region name, ex: “us-west-2”
Enter default output format, ex: “json”
4. Deploy to S3 Bucket
- list all buckets to get desired bucket name
aws s3 ls
- change directory to build directory
cd ${BUILDDIRECTORY}
cd dist/ng-mruanova
- upload all files in current directory to desired s3 bucket
aws s3 sync . s3://${BUCKETNAME}
aws s3 sync . s3://mybucket1234567890
5. Invalidate CloudFront
- invalidate all files in distribution
aws cloudfront create-invalidation — distribution-id ${DISTRIBUTIONID} — paths ‘/*’
aws cloudfront create-invalidation — distribution-id oai1234567890 — paths ‘/*’