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

为什么 AWS HttpApi 不需要 Cloudformation Resource 声明?

如何解决为什么 AWS HttpApi 不需要 Cloudformation Resource 声明?

我正在与 AWS 官方 tutorial 合作研究如何创建 RESTful CRUD API,并且 YML 模板不包含 AWS Class 声明。

AWS::Serverless::Api

但是,在另一个使用 RestApitutorial example 上,可以在 YML 模板中找到 API 资源的声明。

AWstemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Example template for an HTTP API that creates,updates,and deletes items in DynamoDB
  
Globals:
  Function:
    Timeout: 10

Resources:
  DDBHandlerFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: dynamo-handler/
      Handler: app.handler
      Runtime: nodejs12.x
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref ItemsTable
      Events:
        GetAllItems:
          Type: HttpApi
          Properties:
            Path: /items
            Method: GET
        GetAnItem:
          Type: HttpApi
          Properties:
            Path: /items/{id}
            Method: GET
        DeleteAnItem:
          Type: HttpApi
          Properties:
            Path: /items/{id}
            Method: DELETE
        CreateOrUpdateItem:
          Type: HttpApi
          Properties:
            Path: /items
            Method: PUT

  ItemsTable:
    Type: AWS::Serverless::SimpleTable
    Properties:
      PrimaryKey:
        Name: id
        Type: String
      TableName: http-crud-tutorial-items

Outputs:
  ApiEndpoint:
    Description: "The invoke URL for our HTTP API"
    Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/items"
  Function:
    Description: "DynamoDB handler function ARN"
    Value: !GetAtt DDBHandlerFunction.Arn

这是为什么?这是设计使然吗,因为 HttpApi 被认为是“轻量级”的?

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