k1LoW / serverless-s3-sync

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

Lifecycle #49

Closed ergousha closed 4 years ago

ergousha commented 4 years ago

Using hooks, I run a bash script to update a file with an endpoint address. I want to run s3-sync after updating the file. However s3-sync runs at first uploading the old file. How can I control the sequence of running?

nibynool commented 4 years ago

I'm not sure how best to handle this. The hooks used by this plugin are defined at https://github.com/k1LoW/serverless-s3-sync/blob/d424ac4eff73b44c6b6dbf01e8c690a920c3d048/index.js#L29-L34

You could make sure that your bash script is using hooks that are defined earlier in the process, or you may need to look at how SLS prioritises the hook order (they may be run in parallel).

Apart from pointing you to the hooks being used, I don't think this is a problem that can be resolved by the plugin (unless you want to create a feature request for a hook/event system within the plugin and then offer some code to help solve it).

nibynool commented 4 years ago

I should add, in my CI/CD pipeline I run sls deploy --nos3sync as one step and then sls s3sync:sync as an additional step. This may do what you want if you run your bash script between the two phases.

nibynool commented 4 years ago

@ergousha if you are happy with my response as a resolution can you please close this issue? If you feel it needs a better response can you please provide some additional information as to how you would like it actioned.