【发布时间】:2023-03-07 11:28:01
【问题描述】:
我正在尝试创建一个模板,以便当我调用api/divide/inputvalue 时,api 会从DynamoDB 发回对应于inputvalue 映射的响应。
它非常简单,因为我直接从 db 获取值而没有任何业务逻辑,因此我不需要任何 lambda。但是我谷歌搜索的所有示例或他们使用 lambdas 的所有教程,我现在迷失了如何在没有 lambda 的情况下使其工作
这是我目前所拥有的。因为我没有在ApiGateway::Method 中提供Uri,所以这个模板现在有错误。这就是我目前所坚持的。
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"Deployment": {
"Type": "AWS::ApiGateway::Deployment",
"Properties": {
"RestApiId": { "Ref": "restApiName" },
"Description": "First Deployment",
"StageName": "StagingStage"
},
"DependsOn" : ["restApiMethod"]
},
"restApiMethod": {
"Type": "AWS::ApiGateway::Method",
"Properties": {
"AuthorizationType": "NONE",
"HttpMethod": "GET",
"ResourceId": {"Ref": "apiRestResource"},
"RestApiId": {"Ref": "restApiName"},
"Integration": {
"Type": "AWS",
"IntegrationHttpMethod": "GET",
"IntegrationResponses": [{"StatusCode": 200}],
"Uri": { "Fn::Sub":"arn.aws.apigateway:${AWS::Region}:dynamodb:action/${restApiName.Arn}"}
},
"MethodResponses": [{"StatusCode": 200}]
},
"DependsOn": ["apiRestResource"]
},
"apiRestResource": {
"Type": "AWS::ApiGateway::Resource",
"Properties": {
"RestApiId": {"Ref": "restApiName"},
"ParentId": {
"Fn::GetAtt": ["restApiName","RootResourceId"]
},
"PathPart": "divide"
},
"DependsOn": ["restApiName"]
},
"restApiName": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": {
"Name": "CalculationApi"
}
}
}
}
【问题讨论】:
标签: amazon-web-services amazon-dynamodb aws-api-gateway amazon-cloudformation