I want to keep translations (json), audio and images separate from my lambda function as they can be independently updated. Now that I have a bucket created, what do I need to do so that when I execute serverless deploy specified files of various mime types are uploaded to specified bucket paths?
Is there already a serverless plugin that does this? Is this something that is available via CloudFormation?
From what I have seen from example code is that many choose to use the aws cli in their build options along with sls deploy in order to upload files to s3 with MIME types when they deploy. This is what I use in my work flow also, I have not come across a way to do this via cloud formation or directly through sls deploy.
Example uploading file to s3 bucket with css MIME via aws cli:
aws s3 cp /yourpath/style.css s3://yourbucket --content-type âtext/cssâ
When you say âbuild optionsâ are you talking about something built into sls or are you referring to npm scripts or tools like Grunt, Gulp or Webpack?
How would you tie this into sls deploy?
Do you have a sample on GitHub or elsewhere?
I refer to production build software like grunt, gulp and webpack. Here is one example of an implementation using webpack https://github.com/serverless/serverless-graphql/blob/master/package.json. In the package.json they use aws s3 sync to upload the frontend to s3 bucket and sls deploy in their webpack build options. I doing something similar but with bash scripting and Leiningen for clojurescript builds @ github.
In my serverless handler.js file I need to know the name of the S3 bucket and key that was created and synched in my npm script using the aws cli. I want this config info for the S3 bucket and key in only one location (my-config.js, my-config.json, package.json or other).
What ways would you recommend so that the config is defined once and can be used in my build/deploy scripts as well as the Lambda function code?