Skip to content

Simple Amazon Simple Storage Service syncing between VSCode local workspace and S3 bucket

License

Notifications You must be signed in to change notification settings

kokoabim/vscode-simple-s3-sync

Repository files navigation

Features

Sync VS Code local workspace files and directories with an AWS S3 bucket (or a subfolder). There are three types of syncs:

  1. Sync: keep local workspace and S3 bucket the same. Use this by default.
  2. Upload-only: S3 bucket matches local workspace.
  3. Download-only: local workspace matches S3 bucket.

(Types 2 and 3 are most likely used only once upon initial local workspace set up.)

S3 target folder

Either the S3 bucket root is used or an S3 bucket subfolder if folder is specified in settings.

Including and excluding files and directories

In the workspace settings file, specify glob patterns to include and exclude.

Deleting... it's trash, really

When files are "deleted", they are moved under a .simple-s3-sync.trash folder in a new timestamped subfolder, named in the format of yyyy-MM-dd_HH-mm-ss, with files' relative last modified times, in the same format, appended to filenames along with original file extensions. (In a future release, use of a trash folder will be configurable with extension settings.) Files deleted locally are stored in a local trash folder while files deleted on S3 are stored in a S3 trash folder.

Files are deleted when its counterpart copy (local vs S3) no longer exists and its modified time (stored in the settings file on syncs) still match. For example, if foo.txt has been previously synced and the file is deleted in the local workspace, upon a subsequent default sync, if its S3-counterpart exists and the S3 file modified time matches that of the remote modified time stored in the settings file, then it is "deleted" on S3 (i.e. moved to the S3 trash folder).

Ignored if not included or excluded

When syncing, files that do not match the include and exclude settings are not deleted, uploaded or downloaded, i.e. they are ignored, even when performing upload-only and download-only syncs.

Requirements

  • Read and write permissions to an AWS S3 bucket.
  • AWS Command Line Interface (AWS CLI) installed — download here.
  • AWS credentials stored — ~/.aws/credentials or %UserProfile%\.aws\credentials

Getting Started

  1. Satisfy requirements.
  2. Open a VS Code workspace (i.e. a folder).
  3. Create workspace settings file manually or using S5: Create Simple S3 Sync workspace settings file command.
  4. Configure workspace settings file.
  5. Perform a sync using one of three sync types described above via S5-prefixed commands. Most likely the S5: Sync between local workspace and S3 bucket command.
    • Note: Before the actual sync occurs, you'll be able to review what will be performed in an output channel.

Extension Settings

None. Settings are per-workspace in a .simple-s3-sync.json file.

Workspace Settings File

A .simple-s3-sync.json workspace settings file is required for syncing. It can be generated by use of the S5: Create Simple S3 Sync workspace settings file command.

A synced object array property is auto-generated in the workspace settings file. Do not modify it. It keeps track of what files have been synced and their relative modified times between local (workspace) and remote (S3).

JSON schema for validation is added with this extension.

The .simple-s3-sync.json workspace settings file and .simple-s3-sync.trash folder are always excluded.

{
    "profile": "",
    "bucket": "",
    "folder": "",
    "include": [],
    "exclude": []
}

Known Issues

  • Trash folders (.simple-s3-sync.trash) both created locally (workspace) and remotely (S3) are not truncated. User is required to clean them out (for now).
  • Empty subdirectories are left when deleting local workspace files. User is required to delete them if not needed anymore (for now).
  • While the user will be shown what all will be deleted, uploaded and/or downloaded before a sync is run, there is currently no way to abort a sync once started. (I guess other than closing VS Code itself.)

Changelog / Release Notes

2023-08-04 — 0.0.3

  • Added extension settings to set S3 object content-type by file extension on uploads. This addresses an issue with the default content-type being used for static websites hosted on S3.
  • Fixed issue with folder setting being written as null.

2023-08-04 — 0.0.2

  • Added Getting Started section to README.md.
  • Minor changes to default exclude values.

2023-08-02 — 0.0.1

  • Initial release of something functional.

About

Simple Amazon Simple Storage Service syncing between VSCode local workspace and S3 bucket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published