gpt4 book ai didi

amazon-web-services - AWS Proton 参数 - 阐明如何在 CF 模板中使用 schema.yaml 参数

转载 作者:行者123 更新时间:2023-12-03 07:41:26 28 4
gpt4 key购买 nike

浏览完文档和示例后,我还没有弄清楚 schema.yaml 文件中的参数到底用在哪里。

在此处使用 AWS 代码示例:https://github.com/aws-samples/aws-proton-sample-templates/blob/main/lambda-crud-svc/service/schema/schema.yaml

schema.yaml 文件的相关部分:

schema:
format:
openapi: "3.0.0"
service_input_type: "CrudServiceInput"
pipeline_input_type: "PipelineInputs"

types:
CrudServiceInput:
type: object
description: "Input properties for a Lambda backed CRUD API. When given a resource name, this input will be used to generate Create, Read, Update and Delete API methods and lambdas."
properties:
resource_name:
type: string
description: "The resource to generate a CRUD API for"
minLength: 1
maxLength: 50
default: "greeting"
resource_handler:
type: string
description: "The handler path to find the CRUD methods for this API"
minLength: 1
maxLength: 50
default: "index"
lambda_memory:
type: number
description: "The size of your Lambda functions in MB"
default: 512
minimum: 1
maximum: 3008
...

我希望在 cloudformation.yaml 文件中我能够引用 {{service_input_type.resource_name}} ,但它被称为 {{service.resource_name}} .

假设 Proton 以某种方式将 service 命名空间映射到 service_input_type 中的值。然而

当您在同一个service_input_type中使用“lambda_memory”参数的逻辑时对象,它不起作用,因为在模板文件中它将此引用为 service_instance.lambda_memory

谁能澄清以下问题:

  1. schema.yaml 参数是如何在cloudformation.yaml 模板?
  2. 进一步...“xx-spec.yaml”如何文件混合在一起。我假设它们已合并到服务中创建实例时使用模板,但参数命名约定也与上面的模板参数不同。

最佳答案

您应该始终使用 service_instance 作为命名空间,但

  1. 如果您要参数化管道模板,则可以在其中使用 service
  2. 如果您引用的是名称,则可以在其中使用 service_nameservice_instance_name 变量(无命名空间)。

Proton 服务最终是具有管道的服务实例的集合。当 Proton 配置基础设施时,它将为每个实例创建一个 CloudFormation 堆栈,因此参数始终在实例级别应用。管道是一个异常(exception),因为它不属于单个环境,因此在某些情况下,您可能需要引用整个服务。

根据 xx-spec.yaml 文件 - 这些实际上是开发人员可能提供的参数的反射(reflect)。如果您使用 Proton UX 创建新服务,Proton 将输出类似的文件并存储它以反射(reflect)该特定服务的参数。

关于amazon-web-services - AWS Proton 参数 - 阐明如何在 CF 模板中使用 schema.yaml 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66269304/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com