微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决AWS Proton 参数 - 阐明如何在 CF 模板中使用 schema.yaml 参数

在阅读文档和示例之后,我还没有弄清楚 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 堆栈,因此参数始终应用于实例级别。管道是一个例外,因为它不属于单个环境,因此在某些情况下,您可能需要将服务作为一个整体来引用。

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。