k1LoW / serverless-s3-sync

A plugin to sync local directories and S3 prefixes for Serverless Framework :zap:
183 stars 70 forks source link

Add option to only sync specified bucket(s) #34

Closed ziktar closed 4 years ago

ziktar commented 4 years ago

I wanted to only sync certain buckets at certain times, thus added this option. Hope it's helpful.

k1LoW commented 4 years ago

Hi @ziktar . Thank you for your commit ! Looks useful !

But, I think serverless ( and serverless-s3-sync ) should be declarative. So I think it is better not to add --bucket option.

Thank you.

ziktar commented 4 years ago

Understood; would you accept a pull request that adds a config option that to only sync if an environment variable is set then?

The use case is the same as that for the "sls deploy function". In my environment, I have a serverless setup that deploys multiple different microservices which have both backends running on AWS Lambda and front-ends of HTML/JS hosted on S3. In some cases of deploying to the test server, it is cheaper & faster to deploy only one of the microservices, which is a one function & one s3 bucket. The "sls deploy function" command allows for deploying just the lambda function, but as is, serverless-s3-sync will deploy all of the configured S3 buckets.

If not, I understand, and I'll just keep my fork. Thanks for your time & the product itself!

k1LoW commented 4 years ago

The use case is the same as that for the "sls deploy function". In my environment, ~

fmm...right.

Give me some time to think about the implementation. 🙏

k1LoW commented 4 years ago

@ziktar

I propose we make sls s3sync to the same as sls deploy commands.

All with CFn One without CFn
deploy sls deploy sls deploy function -f functionName
s3sync sls s3sync sls s3sync bucket -b bucketName ( or sls s3sync dir -d localDir )

What do you think?

ziktar commented 4 years ago

That makes a lot of sense! I'll take a look at updating my code to follow this format when I get a chance.

nibynool commented 4 years ago

@ziktar any intention to work on this?

ziktar commented 4 years ago

I updated the pull request to use the sub-command option, aka "sls s3sync bucket -b bucketName" will sync just the one bucket.

When updating the metadata syncing code to only sync the metadata for the given bucket, I noticed that the code was not updated to handle if the configuration had just a bucketNameKey instead of bucketName , so I updated that as well.

Let me know what you think of the update.

k1LoW commented 4 years ago

@ziktar GREAT!!! THANK YOU !!!!!

k1LoW commented 4 years ago

Released as v1.12.0.