{"id":17449410,"url":"https://github.com/klaemo/s3-website","last_synced_at":"2025-04-06T20:10:10.649Z","repository":{"id":25453823,"uuid":"28883938","full_name":"klaemo/s3-website","owner":"klaemo","description":":cloud: Easily publish static websites to Amazon S3.","archived":false,"fork":false,"pushed_at":"2022-01-10T15:56:54.000Z","size":63,"stargazers_count":103,"open_issues_count":18,"forks_count":38,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T18:55:21.842Z","etag":null,"topics":["aws","aws-s3","javascript","nodejs","s3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klaemo.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-06T21:15:47.000Z","updated_at":"2025-01-24T00:03:19.000Z","dependencies_parsed_at":"2022-08-06T05:01:02.524Z","dependency_job_id":null,"html_url":"https://github.com/klaemo/s3-website","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaemo%2Fs3-website","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaemo%2Fs3-website/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaemo%2Fs3-website/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaemo%2Fs3-website/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klaemo","download_url":"https://codeload.github.com/klaemo/s3-website/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543591,"owners_count":20955865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-s3","javascript","nodejs","s3"],"created_at":"2024-10-17T21:38:51.037Z","updated_at":"2025-04-06T20:10:10.625Z","avatar_url":"https://github.com/klaemo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## s3-website\n\nEasily publish static websites to Amazon S3. TLS encryption can be enabled via Cloudfront.\n\nCreates a bucket with the specified name and enables static website hosting on it. Also, sets up a public-read bucket policy.\n\nYour AWS credentials should either be in `~/.aws/credentials`, a file in the local directory entitled .env with the values\n```\nAWS_ACCESS_KEY_ID=MY_KEY_ID\nAWS_SECRET_ACCESS_KEY=MY_SECRET_KEY\n```\n or in the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.\n\nYour website policy and configuration will only be sent to S3 when it differs\nfrom the existing.\n\n### Note!\n\nBecause of limitations of the S3 API, any changes made to the website policy or\nconfiguration in the S3 web interface, or elsewhere, will be overwritten by the\nsettings provided to `s3-website`.\n\n### Installation\n\n`s3-website` is a [node.js](http://nodejs.org) program/module.\n\n```\nnpm install -g s3-website\n```\n\n\n### Usage (CLI)\n\n```\n\n  $ s3-website -h\n  Commands:\n\n    create [options] \u003cdomain\u003e      Will create and configure an s3 website\n    deploy [options] \u003cupload-dir\u003e  Will push contents of directory to specified s3 website\n```\nTo see options for each command  `s3-website command -h`\n\n#### Create\n  Usage `s3-website create \u003cdesired.bucket.name\u003e [options]`\n  * Will create a new bucket with desired name\n  * Will configure bucket for static hosting\n\n#### Deploy\n  Usage `s3-website deploy \u003cdirectory-to-upload\u003e [options]`\n  * Will upload all contents of directory to bucket, replacing existing files\n  * Bucket can be specified by providing command line argument -d, or --domain\n    followed by the name of the s3 bucket. If no option is provided s3-website\n    will look for config file written when bucket is created.\n  ** Because there is an issue in the command line library, you must to put the \"-d\" option last.\n    The next dependency version should fix this issue\n\n\nAll the options are optional ;-).\n\n`s3-website -r eu-central-1 cool.website.me` creates a website bucket with the following URL `http://cool.website.me.s3-website.eu-central-1.amazonaws.com`.\nYou can then set up a CNAME record for `cool.website.me` pointing to that hostname.\n\nFor the TLS related options take a look at the [cloudfront-tls](https://github.com/klaemo/cloudfront-tls) readme.\n\n### Usage (API)\n\n```javascript\nconst create = require('s3-website').s3site;\n\ncreate({\n  domain: 'test.site.me', // required, will be the bucket name\n  region: 'eu-central-1', // optional, default: us-east-1\n  index: 'index.html', // optional index document, default: index.html\n  error: '404.html', // optional error document, default: none\n  exclude: ['.git/*', '.gitignore'], // optional path patterns to be excluded from being created/updated/removed, default: [], `*` is the wildcard\n  routes: [{\n    Condition: {\n        KeyPrefixEquals: 'foo/'\n    },\n    Redirect: {\n        HostName: 'foo.com'\n    }\n  }]\n}, (err, website) =\u003e {\n  if(err) {\n    throw err;\n  }\n  console.log(website);\n})\n```\n\nYou can also pass in the same the TLS related options as in [cloudfront-tls](https://github.com/klaemo/cloudfront-tls). So you might want to take a look at its readme if you want to use your own certificates.\n\nIf you want to deploy using the API, create an `s3` instance:\n\n```javascript\nconst deploy = require('s3-website').deploy\n    , config = require('./config')\n    , AWS = require('aws-sdk')\n    , s3 = new AWS.S3({ region: config.region });\n\ndeploy(s3, config, (err, website) =\u003e {\n  if(err) {\n    throw err;\n  }\n  console.log(website);\n})\n```\n\n### Routing Rules\n\n`RoutingRules` can be provided via cli and API. From the cli you will need to provide the path to\na file that can be loaded via `require`, that is to say, a `.js` or `.json` file. This file\nshould export an array of rules that conform to the [S3 Routing Rules syntax](http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax). Likewise, you can provide an\narray of rules to the API with the `routes` option.\n\n### Redirecting All Requests\nTo redirect all requests to another domain eg: www -\u003e non www\nYou can use the rederectall option. NOTE: index, error, and routing rules are not needed when redirecting all requests to another domain.\n```javascript\nconst create = require('s3-website').s3site;\n\ncreate({\n  domain: 'www.site.me', // required, will be the bucket name\n  region: 'eu-central-1', // optional, default: us-east-1\n  redirectall: 'site.me'\n}, (err, website) =\u003e {\n  if(err) {\n    throw err;\n  }\n  console.log(website);\n})\n```\n\n### Custom Content Types\n\nSometimes you may want to change the Content Type header for specific files, for example, serve from S3\n`php` files as HTML. You can now pass an object (`contentTypes`) describing your custom needs:\n\n```\nconfig.contentTypes = {\n  php: 'text/html'\n}\n\ndeploy(s3, config, (err, website) =\u003e {\n  if(err) {\n    throw err;\n  }\n  console.log(website);\n})\n```\n\n\n### Contributors\n\n- [mshick](https://github.com/mshick)\n- [rgruesbeck](https://github.com/rgruesbeck)\n- [nick-benoit14](https://github.com/nick-benoit14)\n- [simoncurd](https://github.com/simoncurd)\n- [StaymanHou](https://github.com/StaymanHou)\n- [ChainsawHunter](https://github.com/ChainsawHunter)\n- [vladejs](https://github.com/vladejs)\n- [rlyle](https://github.com/rlyle)\n### License\nISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklaemo%2Fs3-website","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklaemo%2Fs3-website","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklaemo%2Fs3-website/lists"}