我能否将 AWS Cloud Formation 资源语法用于 SAM 模板,反之亦然?
Can I use the AWS Cloud Formation resource syntax into SAM template or vice-versa?
最近,我开始学习 AWS Cloud Formation (CF) 和 AWS Serverless Application Model (SAM)。我发现它的模板文件中的语法存在差异。例如,要在 SAM 中创建一个 Lambda 资源,我们会这样声明:-
Resources:
HelloLambda:
Type: AWS::Serverless::Function
而在CF中,我们这样声明:-
Resources:
HelloLambda:
Type: AWS::Lambda::Function
不仅仅是因为 Lambda 很少 attributes/properties 在 SAM 中与 CF 不同。
我还是摸不着头脑,一头雾水。我有一些疑问,如果您能消除我的疑虑,我将不胜感激:-
- 如果 CF 已经作为 AWS 云的 IaC(基础设施即代码)发挥了巨大的作用,那么还需要 SAM 吗?
- 为什么有人更喜欢 SAM 而不是 CF?
- 最后,我可以使用 SAM 资源(语法)在 CF 中编写,反之亦然,例如,我可以在普通 CF 模板中使用以下语法声明 Lambda,反之亦然:-
资源:
你好拉姆达:
输入:AWS::Serverless::Function
干杯,
- What was the need for SAM, if CF was already doing great things as IaC (Infrastructure as Code) for AWS Cloud?
它简化了涉及 lambda 和 API 网关 的开发——一个非常流行的组合。在纯 CFN 中做同样的事情,将需要额外的步骤(例如,手动设置集成方法),许多人不想或不需要知道如何制作。 SAM 还具有 自定义命令行工具 ,它可以帮助您 运行 并在本地测试您的 lambda+api 网关并提供 test events not available through CFN, or hides complexities associated with deployments of your functions through CodeDeploy 的数量。仅使用 CFN 无法轻松做到这一点。
- Why somebody would prefer to SAM instead of CF?
能够轻松地在本地测试事物并结合与 CodeDeploy 的简化集成非常有用。因此,这对于想要 更专注于为他们的应用程序编写代码 而不是花费大量时间从头开始设置所有内容的人来说是有益的,这更像是 DevOps 的工作。
Any finally, can I use the SAM resources (syntactical) to write in CF or vice-versa, for instance, can I declare a Lambda using the following syntax in a normal CF template or vice-versa:-
SAM 模板可以包含 CFN 资源,但反之则不行。 SAM 中的 Resources 部分:
- This section is similar to the Resources section of AWS CloudFormation templates. In AWS SAM templates, this section can contain AWS SAM resources in addition to AWS CloudFormation resources.
最近,我开始学习 AWS Cloud Formation (CF) 和 AWS Serverless Application Model (SAM)。我发现它的模板文件中的语法存在差异。例如,要在 SAM 中创建一个 Lambda 资源,我们会这样声明:-
Resources:
HelloLambda:
Type: AWS::Serverless::Function
而在CF中,我们这样声明:-
Resources:
HelloLambda:
Type: AWS::Lambda::Function
不仅仅是因为 Lambda 很少 attributes/properties 在 SAM 中与 CF 不同。
我还是摸不着头脑,一头雾水。我有一些疑问,如果您能消除我的疑虑,我将不胜感激:-
- 如果 CF 已经作为 AWS 云的 IaC(基础设施即代码)发挥了巨大的作用,那么还需要 SAM 吗?
- 为什么有人更喜欢 SAM 而不是 CF?
- 最后,我可以使用 SAM 资源(语法)在 CF 中编写,反之亦然,例如,我可以在普通 CF 模板中使用以下语法声明 Lambda,反之亦然:-
资源: 你好拉姆达: 输入:AWS::Serverless::Function
干杯,
- What was the need for SAM, if CF was already doing great things as IaC (Infrastructure as Code) for AWS Cloud?
它简化了涉及 lambda 和 API 网关 的开发——一个非常流行的组合。在纯 CFN 中做同样的事情,将需要额外的步骤(例如,手动设置集成方法),许多人不想或不需要知道如何制作。 SAM 还具有 自定义命令行工具 ,它可以帮助您 运行 并在本地测试您的 lambda+api 网关并提供 test events not available through CFN, or hides complexities associated with deployments of your functions through CodeDeploy 的数量。仅使用 CFN 无法轻松做到这一点。
- Why somebody would prefer to SAM instead of CF?
能够轻松地在本地测试事物并结合与 CodeDeploy 的简化集成非常有用。因此,这对于想要 更专注于为他们的应用程序编写代码 而不是花费大量时间从头开始设置所有内容的人来说是有益的,这更像是 DevOps 的工作。
Any finally, can I use the SAM resources (syntactical) to write in CF or vice-versa, for instance, can I declare a Lambda using the following syntax in a normal CF template or vice-versa:-
SAM 模板可以包含 CFN 资源,但反之则不行。 SAM 中的 Resources 部分:
- This section is similar to the Resources section of AWS CloudFormation templates. In AWS SAM templates, this section can contain AWS SAM resources in addition to AWS CloudFormation resources.