在 SAM(亚马逊的无服务器应用程序模型)中创建代理资源的要求显然很简单。事实上如此简单以至于亚马逊的文档似乎将其作为练习留给读者!
我想创建一个 AWS API Gateway 全能端点来将所有内容代理到另一个 HTTP 服务。
在 AWS 控制台中,我尝试构建的配置如下所示:
我在此处看到了 Christian Johansen 的这篇优秀文章和他的相关 Stack Overflow 问题,了解如何在 CloudFormation 中做同样的事情。我想我可以只在 SAM 中使用该代码,但是,SAM 具有其隐式和显式 API,因此如果“正确的方法”是引用隐式资源,我想避免创建显式资源。
有谁知道如何做到这一点?
amazon-web-services aws-serverless aws-sam serverless-application-model
我正在尝试使用无服务器离线在本地开发/模拟我的 API 网关。我的 API 网关自由地使用了HTTP 代理集成。生产资源如下所示:
我根据一些文档和讨论创建了一个无服务器离线配置,这些文档和讨论表明可以使用 Cloud Formation 配置定义 HTTP 代理集成:
我已根据我的目的改编了上述两个配置示例,请参见下文。
有什么提示,我可能在这里做错了什么?
plugins:
- serverless-offline
service: company-apig
provider:
name: aws
stage: dev
runtime: python2.7
resources:
Resources:
# Parent APIG RestApi
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: company-apig
Description: 'The main entry point of the APIG'
# Resource /endpoint
EndpointResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Fn::GetAtt:
- ApiGatewayRestApi
- RootResourceId
PathPart: 'endpoint' …Run Code Online (Sandbox Code Playgroud) aws-api-gateway serverless-framework serverless serverless-offline