{"id":13565918,"url":"https://github.com/k1LoW/serverless-s3-sync","last_synced_at":"2025-04-03T23:30:45.094Z","repository":{"id":23198537,"uuid":"98404411","full_name":"k1LoW/serverless-s3-sync","owner":"k1LoW","description":"A plugin to sync local directories and S3 prefixes for Serverless Framework :zap:","archived":false,"fork":false,"pushed_at":"2024-11-25T08:43:33.000Z","size":681,"stargazers_count":184,"open_issues_count":31,"forks_count":71,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T19:03:49.363Z","etag":null,"topics":["aws","s3","serverless-framework"],"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/k1LoW.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"k1LoW","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-07-26T09:20:05.000Z","updated_at":"2025-03-04T16:11:35.000Z","dependencies_parsed_at":"2024-02-27T21:46:23.736Z","dependency_job_id":"06acae6a-39de-4b8a-912b-076ce4580aa3","html_url":"https://github.com/k1LoW/serverless-s3-sync","commit_stats":{"total_commits":140,"total_committers":43,"mean_commits":3.255813953488372,"dds":0.6428571428571428,"last_synced_commit":"107746b583982ec71d2ba594c5f7aa20f1d6bd8e"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fserverless-s3-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fserverless-s3-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fserverless-s3-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k1LoW%2Fserverless-s3-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k1LoW","download_url":"https://codeload.github.com/k1LoW/serverless-s3-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097611,"owners_count":20883121,"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","s3","serverless-framework"],"created_at":"2024-08-01T13:01:57.892Z","updated_at":"2025-04-03T23:30:44.625Z","avatar_url":"https://github.com/k1LoW.png","language":"JavaScript","funding_links":["https://github.com/sponsors/k1LoW"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Serverless S3 Sync [![npm](https://img.shields.io/npm/v/serverless-s3-sync.svg)](https://www.npmjs.com/package/serverless-s3-sync)\n\n\u003e A plugin to sync local directories and S3 prefixes for Serverless Framework :zap: .\n\n## Use Case\n\n- Static Website ( `serverless-s3-sync` ) \u0026 Contact form backend ( `serverless` ) .\n- SPA ( `serverless` ) \u0026 assets ( `serverless-s3-sync` ) .\n\n## Install\n\nRun `npm install` in your Serverless project.\n\n```sh\n$ npm install --save serverless-s3-sync\n```\n\nAdd the plugin to your serverless.yml file\n\n```yaml\nplugins:\n  - serverless-s3-sync\n```\n\n### Compatibility with Serverless Framework\n\nVersion 2.0.0 is compatible with Serverless Framework v3, but it uses the legacy logging interface. Version 3.0.0 and later uses the [new logging interface](https://www.serverless.com/framework/docs/guides/plugins/cli-output).\n\n|serverless-s3-sync|Serverless Framework|\n|---|---|\n|v1.x|v1.x, v2.x|\n|v2.0.0|v1.x, v2.x, v3.x|\n|≥ v3.0.0|v3.x|\n\n## Setup\n\n```yaml\ncustom:\n  s3Sync:\n    # A simple configuration for copying static assets\n    - bucketName: my-static-site-assets # required\n      bucketPrefix: assets/ # optional\n      localDir: dist/assets # required\n\n    # An example of possible configuration options\n    - bucketName: my-other-site\n      localDir: path/to/other-site\n      deleteRemoved: true # optional, indicates whether sync deletes files no longer present in localDir. Defaults to 'true'\n      acl: public-read # optional\n      followSymlinks: true # optional\n      defaultContentType: text/html # optional\n      params: # optional\n        - index.html:\n            CacheControl: 'no-cache'\n        - \"*.js\":\n            CacheControl: 'public, max-age=31536000'\n      bucketTags: # optional, these are appended to existing S3 bucket tags (overwriting tags with the same key)\n        tagKey1: tagValue1\n        tagKey2: tagValue2\n\n    # This references bucket name from the output of the current stack\n    - bucketNameKey: AnotherBucketNameOutputKey\n      localDir: path/to/another\n\n    # ... but can also reference it from the output of another stack,\n    # see https://www.serverless.com/framework/docs/providers/aws/guide/variables#reference-cloudformation-outputs\n    - bucketName: ${cf:another-cf-stack-name.ExternalBucketOutputKey}\n      localDir: path\n\n    # Setting the optional enabled field to false will disable this rule.\n    # Referencing other variables allows this rule to become conditional\n    - bucketName: DisabledSync\n      localDir: path\n      enabled: false\n\nresources:\n  Resources:\n    AssetsBucket:\n      Type: AWS::S3::Bucket\n      Properties:\n        BucketName: my-static-site-assets\n    OtherSiteBucket:\n      Type: AWS::S3::Bucket\n      Properties:\n        BucketName: my-other-site\n        AccessControl: PublicRead\n        WebsiteConfiguration:\n          IndexDocument: index.html\n          ErrorDocument: error.html\n    AnotherBucket:\n      Type: AWS::S3::Bucket\n  Outputs:\n    AnotherBucketNameOutputKey:\n      Value: !Ref AnotherBucket\n```\n\n## Usage\n\nRun `sls deploy`, local directories and S3 prefixes are synced.\n\nRun `sls remove`, S3 objects in S3 prefixes are removed.\n\nRun `sls deploy --nos3sync`, deploy your serverless stack without syncing local directories and S3 prefixes.\n\nRun `sls remove --nos3sync`, remove your serverless stack without removing S3 objects from the target S3 buckets.\n\n### `sls s3sync`\n\nSync local directories and S3 prefixes.\n\n### Offline usage\n\nIf also using the plugins `serverless-offline` and `serverless-s3-local`, sync can be supported during development by placing the bucket configuration(s) into the `buckets` object and specifying the alterate `endpoint` (see below).\n\n```yaml\ncustom:\n  s3Sync:\n    # an alternate s3 endpoint\n    endpoint: http://localhost:4569\n    buckets:\n    # A simple configuration for copying static assets\n    - bucketName: my-static-site-assets # required\n      bucketPrefix: assets/ # optional\n      localDir: dist/assets # required\n# ...\n```\n\nAs per [serverless-s3-local's instructions](https://github.com/ar90n/serverless-s3-local#triggering-aws-events-offline), once a local credentials profile is configured, run `sls offline start --aws-profile s3local` to sync to the local s3 bucket instead of Amazon AWS S3\n\n\u003e `bucketNameKey` will not work in offline mode and can only be used in conjunction with valid AWS credentials, use `bucketName` instead.\n\nrun `sls deploy` for normal deployment\n\n### Always disable auto sync\n\n```yaml\ncustom:\n  s3Sync:\n    # Disable sync when sls deploy and sls remove\n    noSync: true\n    buckets:\n    # A simple configuration for copying static assets\n    - bucketName: my-static-site-assets # required\n      bucketPrefix: assets/ # optional\n      localDir: dist/assets # required\n# ...\n```\n\n### Sync on other hooks\n```yaml\ncustom:\n  s3Sync:\n    hooks:\n      # This hook will run after the deploy:finalize hook\n      - after:deploy:finalize\n    buckets:\n    # A simple configuration for copying static assets\n    - bucketName: my-static-site-assets # required\n      bucketPrefix: assets/ # optional\n      localDir: dist/assets # required\n# ...\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1LoW%2Fserverless-s3-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk1LoW%2Fserverless-s3-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk1LoW%2Fserverless-s3-sync/lists"}