Skip to content

Instantly share code, notes, and snippets.

@badbabykosh
Last active July 20, 2017 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badbabykosh/830f65be6614974a9a93 to your computer and use it in GitHub Desktop.
Save badbabykosh/830f65be6614974a9a93 to your computer and use it in GitHub Desktop.
aws_cli_stuff

##general resources

s3 create bucket from cli
http://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html

s3 commands
http://docs.aws.amazon.com/cli/latest/reference/s3/index.html

create a website
http://docs.aws.amazon.com/AmazonS3/latest/dev/HostingWebsiteOnS3Setup.html

http://docs.aws.amazon.com/cli/latest/reference/s3/website.html

upload content via web gui
http://docs.aws.amazon.com/AmazonS3/latest/UG/UploadingObjectsintoAmazonS3.html

copy paste json to make website work http://docs.aws.amazon.com/AmazonS3/latest/dev/HostingWebsiteOnS3Setup.html

static site on aws (cli only)

create a bucket from aws cli
$ aws s3api create-bucket --bucket MyBucket --region us-west-1 --create-bucket-configuration LocationConstraint=us-west-1

configure static website
$ aws s3 website s3://MyBucket/ --index-document index.html --error-document error.html

upload your stuff and exclude things
$ aws s3 sync . s3://MyBucket/ --exclude ".git/*" --exclude "*.idea/*" --exclude "*.DS_Store" --exclude "\node_modules/*"

json to make website work
$aws s3api put-bucket-policy --bucket MyBucket --policy file://policy.json

policy.json

{
  "Version":"2012-10-17",
  "Statement":[{
	"Sid":"PublicReadForGetBucketObjects",
        "Effect":"Allow",
	  "Principal": "*",
      "Action":["s3:GetObject"],
      "Resource":["arn:aws:s3:::MyBucket/*"
      ]
    }
  ]
}

note: just replace MyBucket with the name of your actual bucket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment