1+ {
2+ "Resources" : {
3+ "HttpApiFunction" : {
4+ "Type" : " AWS::Lambda::Function" ,
5+ "Properties" : {
6+ "Code" : {
7+ "S3Bucket" : " sam-demo-bucket" ,
8+ "S3Key" : " todo_list.zip"
9+ },
10+ "Handler" : " index.restapi" ,
11+ "Role" : {
12+ "Fn::GetAtt" : [
13+ " HttpApiFunctionRole" ,
14+ " Arn"
15+ ]
16+ },
17+ "Runtime" : " python3.7" ,
18+ "Tags" : [
19+ {
20+ "Key" : " lambda:createdBy" ,
21+ "Value" : " SAM"
22+ }
23+ ]
24+ }
25+ },
26+ "HttpApiFunctionRole" : {
27+ "Type" : " AWS::IAM::Role" ,
28+ "Properties" : {
29+ "AssumeRolePolicyDocument" : {
30+ "Version" : " 2012-10-17" ,
31+ "Statement" : [
32+ {
33+ "Action" : [
34+ " sts:AssumeRole"
35+ ],
36+ "Effect" : " Allow" ,
37+ "Principal" : {
38+ "Service" : [
39+ " lambda.amazonaws.com"
40+ ]
41+ }
42+ }
43+ ]
44+ },
45+ "ManagedPolicyArns" : [
46+ " arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
47+ ],
48+ "Tags" : [
49+ {
50+ "Key" : " lambda:createdBy" ,
51+ "Value" : " SAM"
52+ }
53+ ]
54+ }
55+ },
56+ "HttpApiFunctionSimpleCasePermission" : {
57+ "Type" : " AWS::Lambda::Permission" ,
58+ "Properties" : {
59+ "Action" : " lambda:InvokeFunction" ,
60+ "FunctionName" : {
61+ "Ref" : " HttpApiFunction"
62+ },
63+ "Principal" : " apigateway.amazonaws.com" ,
64+ "SourceArn" : {
65+ "Fn::Sub" : [
66+ " arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/*" ,
67+ {
68+ "__ApiId__" : {
69+ "Ref" : " MyApi"
70+ },
71+ "__Stage__" : " *"
72+ }
73+ ]
74+ }
75+ }
76+ },
77+ "MyAuthFn" : {
78+ "Type" : " AWS::Lambda::Function" ,
79+ "Properties" : {
80+ "Code" : {
81+ "S3Bucket" : " bucket" ,
82+ "S3Key" : " key"
83+ },
84+ "Handler" : " index.handler" ,
85+ "Role" : {
86+ "Fn::GetAtt" : [
87+ " MyAuthFnRole" ,
88+ " Arn"
89+ ]
90+ },
91+ "Runtime" : " nodejs12.x" ,
92+ "Tags" : [
93+ {
94+ "Key" : " lambda:createdBy" ,
95+ "Value" : " SAM"
96+ }
97+ ]
98+ }
99+ },
100+ "MyAuthFnRole" : {
101+ "Type" : " AWS::IAM::Role" ,
102+ "Properties" : {
103+ "AssumeRolePolicyDocument" : {
104+ "Version" : " 2012-10-17" ,
105+ "Statement" : [
106+ {
107+ "Action" : [
108+ " sts:AssumeRole"
109+ ],
110+ "Effect" : " Allow" ,
111+ "Principal" : {
112+ "Service" : [
113+ " lambda.amazonaws.com"
114+ ]
115+ }
116+ }
117+ ]
118+ },
119+ "ManagedPolicyArns" : [
120+ " arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
121+ ],
122+ "Tags" : [
123+ {
124+ "Key" : " lambda:createdBy" ,
125+ "Value" : " SAM"
126+ }
127+ ]
128+ }
129+ },
130+ "MyApi" : {
131+ "Type" : " AWS::ApiGatewayV2::Api" ,
132+ "Properties" : {
133+ "Body" : {
134+ "openapi" : " 3.0.1" ,
135+ "info" : {
136+ "version" : " 1.0" ,
137+ "title" : {
138+ "Ref" : " AWS::StackName"
139+ }
140+ },
141+ "paths" : {
142+ "/hello" : {
143+ "get" : {
144+ "x-amazon-apigateway-integration" : {
145+ "type" : " aws_proxy" ,
146+ "httpMethod" : " POST" ,
147+ "payloadFormatVersion" : " 2.0" ,
148+ "uri" : {
149+ "Fn::Sub" : " arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations"
150+ }
151+ },
152+ "responses" : {},
153+ "security" : [
154+ {
155+ "LambdaAuth" : []
156+ }
157+ ]
158+ },
159+ "put" : {
160+ "x-amazon-apigateway-integration" : {
161+ "type" : " aws_proxy" ,
162+ "httpMethod" : " POST" ,
163+ "payloadFormatVersion" : " 2.0" ,
164+ "uri" : {
165+ "Fn::Sub" : " arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations"
166+ }
167+ },
168+ "responses" : {},
169+ "security" : [
170+ {
171+ "MyOauth2Authorizer" : [
172+ " scope"
173+ ]
174+ }
175+ ]
176+ },
177+ "post" : {
178+ "x-amazon-apigateway-integration" : {
179+ "type" : " aws_proxy" ,
180+ "httpMethod" : " POST" ,
181+ "payloadFormatVersion" : " 2.0" ,
182+ "uri" : {
183+ "Fn::Sub" : " arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations"
184+ }
185+ },
186+ "responses" : {},
187+ "security" : [
188+ {
189+ "LambdaAuth" : []
190+ }
191+ ]
192+ }
193+ },
194+ "$default" : {
195+ "x-amazon-apigateway-any-method" : {
196+ "x-amazon-apigateway-integration" : {
197+ "type" : " aws_proxy" ,
198+ "httpMethod" : " POST" ,
199+ "payloadFormatVersion" : " 2.0" ,
200+ "uri" : {
201+ "Fn::Sub" : " arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HttpApiFunction.Arn}/invocations"
202+ }
203+ },
204+ "isDefaultRoute" : true ,
205+ "responses" : {},
206+ "security" : [
207+ {
208+ "LambdaAuth" : []
209+ }
210+ ]
211+ }
212+ }
213+ },
214+ "components" : {
215+ "securitySchemes" : {
216+ "LambdaAuth" : {
217+ "type" : " apiKey" ,
218+ "name" : " Unused" ,
219+ "in" : " header" ,
220+ "x-amazon-apigateway-authorizer" : {
221+ "type" : " request" ,
222+ "authorizerUri" : {
223+ "Fn::Sub" : [
224+ " arn:aws-cn:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${__FunctionArn__}/invocations" ,
225+ {
226+ "__FunctionArn__" : {
227+ "Fn::GetAtt" : [
228+ " MyAuthFn" ,
229+ " Arn"
230+ ]
231+ }
232+ }
233+ ]
234+ },
235+ "authorizerPayloadFormatVersion" : 1.0
236+ }
237+ },
238+ "MyOauth2Authorizer" : {
239+ "type" : " oauth2" ,
240+ "x-amazon-apigateway-authorizer" : {
241+ "jwtConfiguration" : {
242+ "audience" : [
243+ " audience1" ,
244+ " audience2"
245+ ],
246+ "issuer" : " https://www.example.com/v1/connect/oidc"
247+ },
248+ "identitySource" : " $request.header.Authorization" ,
249+ "type" : " jwt"
250+ }
251+ }
252+ }
253+ },
254+ "tags" : [
255+ {
256+ "name" : " Tag1" ,
257+ "x-amazon-apigateway-tag-value" : " value1"
258+ },
259+ {
260+ "name" : " Tag2" ,
261+ "x-amazon-apigateway-tag-value" : " value2"
262+ },
263+ {
264+ "name" : " httpapi:createdBy" ,
265+ "x-amazon-apigateway-tag-value" : " SAM"
266+ }
267+ ]
268+ }
269+ }
270+ },
271+ "MyApiApiGatewayDefaultStage" : {
272+ "Type" : " AWS::ApiGatewayV2::Stage" ,
273+ "Properties" : {
274+ "ApiId" : {
275+ "Ref" : " MyApi"
276+ },
277+ "StageName" : " $default" ,
278+ "Tags" : {
279+ "Tag1" : " value1" ,
280+ "Tag2" : " value2" ,
281+ "httpapi:createdBy" : " SAM"
282+ },
283+ "AutoDeploy" : true
284+ }
285+ }
286+ }
287+ }
0 commit comments