Why sam package publishes the artifacts to bucket?

不羁岁月 提交于 2019-12-11 07:49:14

问题


As part of packaging the SAM application, the application published to s3 bucket as shown below:

sam package --template-file sam.yaml --s3-bucket mybucket --output-template-file output.yaml


Why sam package provides --s3-bucket option? Is this mandatory option?

What is the purpose of publishing artifacts to s3 bucket?


回答1:


--s3-bucket option in sam package command is mandatory. What the command does is that it takes your local code, uploads it to S3 and returns transformed template where source location of your local code has been replaced with the S3 bucket URI (URI of object - zipped code - in the S3 bucket).

Main advantage of uploading artifact to S3 is that it is faster to deploy code that already sits within AWS network than send it through the Internet during deployment.

Another thing is that plain CloudFormation let's you inline lambda function code without pushing it to S3 but there are limitations to this approach. If your lambda function needs to use external libraries that are not part of AWS provided lambda environment for a particular runtime or your function's size is big then you still need to zip your function's code together with its dependencies and upload it to S3 before continuing. SAM just makes this easier for you so that you don't have to do this step manually.



来源:https://stackoverflow.com/questions/57121977/why-sam-package-publishes-the-artifacts-to-bucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!