[英]Does AWS sam cli print template.yaml config file with all variables resolved
I have switched from serverless to sam cli.我已经从无服务器切换到 sam cli。 One useful function serverless had was serverless print which allowed you to print the output of your yaml file with all the local variables resolved.
一个有用的 function 无服务器打印是无服务器打印,它允许您打印 yaml 文件的 output 并解析所有局部变量。 This was a useful tool for checking if your syntax is correct or if the variables are resolving as you expect.
这是检查语法是否正确或变量是否按预期解析的有用工具。
Is that any way to do this with AWS sam cli?这有什么方法可以用 AWS sam cli 做到这一点吗?
eg例如
sam print
You can achieve this using Outputs
section of SAM template.您可以使用 SAM 模板的
Outputs
部分来实现此目的。
You can check the AWS SAM template anatomy to understand better.您可以查看AWS SAM 模板剖析以更好地理解。
Outputs (optional)
输出(可选)
The values that are returned whenever you view your stack's properties.
每当您查看堆栈的属性时返回的值。 For example, you can declare an output for an S3 bucket name, and then call the aws cloudformation describe-stacks AWS Command Line Interface (AWS CLI) command to view the name.
例如,您可以为 S3 存储桶名称声明 output,然后调用 aws cloudformation describe-stacks AWS 命令行界面 (AWS CLI) 命令查看名称。 This section corresponds directly with the Outputs section of AWS CloudFormation templates.
此部分直接对应于 AWS CloudFormation 模板的输出部分。
You will need to make use of Intrinsic functions within your Outputs
section to print out the final resolved value at runtime.您将需要使用
Outputs
部分中的内在函数来在运行时打印出最终解析的值。
Outputs:
BackupLoadBalancerDNSName:
Description: The DNSName of the backup load balancer
Value: !GetAtt BackupLoadBalancer.DNSName
Condition: CreateProdResources
InstanceID:
Description: The Instance ID
Value: !Ref EC2Instance
If you just wish to validate if your SAM
is correct or not you could use the following command:如果您只想验证您的
SAM
是否正确,您可以使用以下命令:
$ sam validate
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.