Prequisites: AWS Account
In AWS Console:
- Go to IAM Service and create new group, name it
S3FullAccessGroup
, attach theAmazonS3FullAccess
policy to it. - In IAM Service, add new user. Name it something like
yourName_macbookpro_cli
. Make sure only programmatic access is checked off. Add the user to theS3FullAccessGroup
. - When done with wizard, it will give you your secret access key only ONCE. Don't leave this page yet.
In Local Development Terminal:
- OSX:
brew install awscli
Linux:sudo apt update
sudo apt install awscli
aws configure
- Enter Access Key Id
- Enter Secret Access Key
- Set default region to
us-west-2
(or whatever region you want the cli to default to) - Just press enter when it asks for default output format.
Create new S3 bucket that's public, read only:
aws s3api create-bucket --bucket {my-bucket} --acl public-read --region us-west-2 --create-bucket-configuration LocationConstraint=us-west-2
Configure bucket to serve static website (bucketnames have to be lowercase):
aws s3 website s3://{my-bucket}/ --index-document index.html --error-document index.html
Upload all files in current directory excluding .git folder and apply public-read permissions to all files:
aws s3 sync . s3://{my-bucket} --delete --acl public-read --exclude '.git*'
Delete all files in bucket:
aws s3 rm --recursive s3://{my-bucket}
Delete entire bucket and contents:
aws s3 rb s3://{bucket-name} --force
Navigate to:
http://{my-bucket}.s3-website-us-west-2.amazonaws.com