How to Deploy Hexo Site to AWS S3

1. AWS Sec and AWS Sec Key

Create you own AWS Sec and AWS Sec Key to autodeploy in Hexo.io.

  • Go to AWS Amazon IAM -> Users
  • Click Add User Button
  • Check Access Type -> Programmatic access
  • Choose Attach existing policies directly and add AmazonS3FullAccess policy in it.
  • Copy Access Key Id (aws_key) and Secret access key (aws_secret) in _config.yml.

Additional information in AWS Amazon Iam User Guide

2. Change _config

Add information in _config.yml like this:

# Deployment
deploy:
  type: s3
  bucket: TEST.com
  aws_key: SJFKSDLFKJSLDKFJLSKS  # // Optional, if the environment variable `AWS_ACCESS_KEY_ID` is set
  aws_secret: 23fsdf2ff23f2f24fg3g33gfdgdfgdf #<AWS secret key>  // Optional, if the environment variable `AWS_SECRET_ACCESS_KEY` is set
  aws_cli_profile: https://24234234234.signin.aws.amazo  
  region: eu-west-2 # (London) #<region>  // Optional, see https://github.com/LearnBoost/knox#region
  headers: {CacheControl: 'max-age=604800, public'} #<headers in JSON format> // pass any headers to S3, usefull for metadata cache setting of Hexo assets
  delete_removed: true # <true|false> // if true will delete removed files from S3. Default: true

3. Deploy

Use hexo cli to deploy

hexo deploy

3.1. Deploy Error

Usually you catch next error

INFO  Deploying: s3
INFO  Uploading...
INFO  Deploy done: s3
ERROR Non-file stream objects are not supported with SigV4 in AWS.S3

This error appears because hexo-s3-deploy uses depricated npm package s3 with old package.json dependences file.
yousite\node_modules\s3\package.json shows us that s3 uses old version of aws-sdk.
You have to update it manually. Replce yousite\node_modules\s3\node_modules\aws-sdk with last version aws-sdk.

3.2. Deploy Again

Use hexo cli again

hexo deploy
INFO  Deploying: s3
INFO  Uploading...
INFO  Deploy done: s3
INFO  Done!
0%