简体   繁体   English

SAM/Serverless/CodeBuild 说明

[英]SAM/Serverless/CodeBuild clarification

I am hoping for some clarification around some terms I have been seeing on the web as it pertains to AWS and specifically lambdas.我希望对我在 web 上看到的一些术语进行一些澄清,因为它与 AWS 尤其是 lambdas 相关。 For starters, I would like the know how the commands sam build/deploy work versus setting up a CodeBuild job.对于初学者,我想知道命令sam build/deploy与设置 CodeBuild 作业是如何工作的。 Do I need a CodeBuild job to run those commands?我是否需要 CodeBuild 作业来运行这些命令? What files specifically does the sam deploy command look for? sam deploy命令具体查找哪些文件? Does it look for serverless.yml or template.yml or both?它会寻找serverless.ymltemplate.yml还是两者兼而有之? What is a sam.yml file or are they antiquated?什么是sam.yml文件或者它们已经过时了?

I have an app with a CodeBuild pipeline for a lambda, but I am expanding my repo to contain multiple lambdas and thinking about putting a serverless.yml file in each lambda directory, but I don't want to create a CodeBuild job and buildspec for each one.我有一个带有用于 lambda 的 CodeBuild 管道的应用程序,但我正在扩展我的存储库以包含多个 lambda,并考虑在每个buildspec目录中放置一个serverless.yml文件,但我不想为每一个。 I assume sam deploy searches for all template.yml and serverless.yml files and constructs your stack as a whole (and updates only what needs to be updated?)我假设sam deploy搜索所有template.ymlserverless.yml文件并将您的堆栈作为一个整体构建(并且只更新需要更新的内容?)

App is in Node if curious using API Gateway.如果对使用 API 网关感到好奇,应用程序在 Node 中。 Any insight would be appreciated.任何见解将不胜感激。

I will try to give brief answers:我将尝试给出简短的答案:

  • What does sam deploy do : It will zip the code and create cloudformation yaml file into .aws-sam folder and run cloudformation deploy. sam deploy的作用:它将 zip 代码并在.aws-sam文件夹中创建 cloudformation yaml 文件并运行 cloudformation deploy。
  • Do we need CodeBuild to run same deploy : We still need some server to run sam deploy or build with node installed, which could be a local machine or remote server or a CodeBuild environment.我们是否需要 CodeBuild 来运行相同的部署:我们仍然需要一些服务器来运行 sam deploy 或安装了节点的构建,它可以是本地计算机或远程服务器或 CodeBuild 环境。
  • Do we need multiple templates?我们需要多个模板吗? All Lambdas can be created in single template.所有 Lambda 都可以在单个模板中创建。 But there is limit of 150 resources in cloudformation.但是 cloudformation 中的资源限制为 150 个。 if we have too many functions and APIs in single template, we will easily hit that limit.如果我们在单个模板中有太多的函数和 API,我们很容易达到这个限制。 Each api might get converted into multiple cloud-formation resources.每个 api 都可能转换为多个云形成资源。 ex: 1 lambda function can be iam roles, cloudwatch logs, api routes, methods, integration, event source, etc.例如:1 lambda function 可以是 iam 角色、cloudwatch 日志、api 路由、方法、集成、事件源等。
  • Does sam deploy always looks for template.yaml By default yes, but can be easily overridden by passing --template-file sam deploy --template-file template-x.yml sam deploy是否总是查找template.yaml默认是,但可以通过传递 --template-file sam deploy --template-file template-x.yml轻松覆盖
  • Only changed resources are updated?仅更新更改的资源? Cloudformation update-stack updates only the resources that are changed. Cloudformation 更新堆栈仅更新已更改的资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM