Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support syncing single file #29

Open
Horgix opened this issue Mar 13, 2019 · 5 comments
Open

Support syncing single file #29

Horgix opened this issue Mar 13, 2019 · 5 comments

Comments

@Horgix
Copy link

Horgix commented Mar 13, 2019

Feature request - Support syncing single file

Need

I would like to use this plugin to sync a single local file to an S3 bucket created by Serverless. However, this plugin only supports syncing directories, as stated in the description.

Would you be open to extending this plugin so it can also sync simple files?

Contribution

I've already modified it on my side to make it work and am wondering if I could contribute it back.

Implementation

The main question is regarding the breaking change possibility.

While it is possible to just handle single file with its path passed through the current localDir parameter, it isn't really logical for users to path a file to something called localDir imho.

To avoid that, it would be possible to rename this field into localPath but it would then be a breaking change. It's also possible to introduce a new parameter called localFile which would be mutually exclusive with localDir, but that adds more conditional logic to the code.

What do you think about all of this? I'm ready to send a PR with whatever will be needed.

@programmer04
Copy link

Howdy @Horgix @k1LoW
What is the status of this issue? This feature will be useful also for me ;) Could @Horgix send this PR? I think localDir can be reused for single files too (only mention this in docs).

@k1LoW
Copy link
Owner

k1LoW commented Aug 15, 2019

@Horgix sorry for too late repry 🙏

localPath is good idea !

I think

  • create localPath that allow dir and single files.
  • show deprecation message if using localDir

@cmjchrisjones
Copy link

@k1LoW @Horgix I've just found myself needing this very feature, it looks like this might have been forgotten about over the last couple of years, is there any chance of seeing this come to fruition at all or if not would you be willing to share your amendments and/or publish a forked version of it @Horgix

Regards

Chris

@cmjchrisjones
Copy link

cmjchrisjones commented Jan 15, 2023

In the meantime a workaround that I have found is thus:

given I only want to sync a single file (in my case index.html), move it into a src folder

in the serverless.yml file, update the custom section and the WebsiteConfiguration.IndexDocument like so:

custom:
  siteName: <your-site-name>
  s3Sync:
    - bucketName: ${self:custom.siteName}
      localDir: src/

resources:
  Resources:
    StaticSite:
      Type: AWS::S3::Bucket
      Properties:
        AccessControl: PublicRead
        BucketName: ${self:custom.siteName}
        WebsiteConfiguration:
          IndexDocument: ./src/index.html

@msudgh
Copy link

msudgh commented Jul 15, 2023

Hey @k1LoW,
I investigated the feature, and IMO requires a recursive implementation on the given path.
I want to utilize it as a plugin to upload a single file or directory.
It needs to detect the type of given path and consider the process to perform.

Appreciate any thoughts or input.

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

No branches or pull requests

5 participants