1+ AWSTemplateFormatVersion : ' 2010-09-09'
2+ Transform : ' AWS::Serverless-2016-10-31'
3+ Description : Baeldung Serverless Application Model Example with Inline Swagger API Definition
4+ Resources :
5+ PersonTable :
6+ Type : AWS::Serverless::SimpleTable
7+ Properties :
8+ PrimaryKey :
9+ Name : id
10+ Type : Number
11+ TableName : Person
12+ StorePersonFunction :
13+ Type : AWS::Serverless::Function
14+ Properties :
15+ Handler : com.baeldung.lambda.apigateway.APIDemoHandler::handleRequest
16+ Runtime : java8
17+ Timeout : 15
18+ MemorySize : 512
19+ CodeUri : ../target/aws-lambda-0.1.0-SNAPSHOT.jar
20+ Policies :
21+ - DynamoDBCrudPolicy :
22+ TableName : !Ref PersonTable
23+ Environment :
24+ Variables :
25+ TABLE_NAME : !Ref PersonTable
26+ Events :
27+ StoreApi :
28+ Type : Api
29+ Properties :
30+ Path : /persons
31+ Method : PUT
32+ RestApiId :
33+ Ref : MyApi
34+ GetPersonByHTTPParamFunction :
35+ Type : AWS::Serverless::Function
36+ Properties :
37+ Handler : com.baeldung.lambda.apigateway.APIDemoHandler::handleGetByParam
38+ Runtime : java8
39+ Timeout : 15
40+ MemorySize : 512
41+ CodeUri : ../target/aws-lambda-0.1.0-SNAPSHOT.jar
42+ Policies :
43+ - DynamoDBReadPolicy :
44+ TableName : !Ref PersonTable
45+ Environment :
46+ Variables :
47+ TABLE_NAME : !Ref PersonTable
48+ Events :
49+ GetByPathApi :
50+ Type : Api
51+ Properties :
52+ Path : /persons/{id}
53+ Method : GET
54+ RestApiId :
55+ Ref : MyApi
56+ GetByQueryApi :
57+ Type : Api
58+ Properties :
59+ Path : /persons
60+ Method : GET
61+ RestApiId :
62+ Ref : MyApi
63+ MyApi :
64+ Type : AWS::Serverless::Api
65+ Properties :
66+ StageName : test
67+ EndpointConfiguration : REGIONAL
68+ DefinitionBody :
69+ swagger : " 2.0"
70+ info :
71+ title : " TestAPI"
72+ paths :
73+ /persons :
74+ get :
75+ parameters :
76+ - name : " id"
77+ in : " query"
78+ required : true
79+ type : " string"
80+ x-amazon-apigateway-request-validator : " Validate query string parameters and\
81+ \ headers"
82+ x-amazon-apigateway-integration :
83+ uri :
84+ Fn::Sub : arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetPersonByHTTPParamFunction.Arn}/invocations
85+ responses : {}
86+ httpMethod : " POST"
87+ type : " aws_proxy"
88+ put :
89+ x-amazon-apigateway-integration :
90+ uri :
91+ Fn::Sub : arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${StorePersonFunction.Arn}/invocations
92+ responses : {}
93+ httpMethod : " POST"
94+ type : " aws_proxy"
95+ /persons/{id} :
96+ get :
97+ parameters :
98+ - name : " id"
99+ in : " path"
100+ required : true
101+ type : " string"
102+ responses : {}
103+ x-amazon-apigateway-integration :
104+ uri :
105+ Fn::Sub : arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetPersonByHTTPParamFunction.Arn}/invocations
106+ responses : {}
107+ httpMethod : " POST"
108+ type : " aws_proxy"
109+ x-amazon-apigateway-request-validators :
110+ Validate query string parameters and headers :
111+ validateRequestParameters : true
112+ validateRequestBody : false
0 commit comments