{
"swagger": "2.0",
"info": {
"title": "My API",
"version": "1.0"
},
"paths": {
"/hello": {
"get": {
"responses": {
"200": {
"description": "Successful response"
}
}
}
}
}
}
在以上示例中,“/hello”是API Gateway的路径。
{
"Type": "AWS::ApiGateway::Method",
"Properties": {
"RestApiId": "xxxxx",
"ResourceId": "xxxxx",
"HttpMethod": "GET",
"AuthorizationType": "NONE",
"Integration": {
"IntegrationHttpMethod": "POST",
"Type": "AWS",
"Uri": { "Fn::Join": [ "", [
"arn:aws:apigateway:",
{ "Ref": "AWS::Region" },
":lambda:path/2015-03-31/functions/",
{ "Fn::GetAtt": [ "MyFunction", "Arn" ] },
"/invocations"
] ] },
"IntegrationResponses": [
{
"StatusCode": 200
}
]
},
"MethodResponses": [
{
"StatusCode": 200
}
]
}
}
在以上示例中,“MyFunction”是Lambda函数的名称。
{
"Type": "AWS::Lambda::Permission",
"Properties": {
"FunctionName": { "Ref": "MyFunction" },
"Action": "lambda:InvokeFunction",
"Principal": "apigateway.amazonaws.com",
"SourceArn": { "Fn::Join": [ "", [
"arn:aws:execute-api:",
{ "Ref": "AWS::Region" },
":",
{ "Ref": "AWS::AccountId" },
":",
{ "Ref": "MyApi" },
"/*/GET/*"
] ] }
}
}
在以上示例中,“MyApi”是API Gateway的名称。