@@ -109,7 +109,6 @@ const httpLambdaIntegration = new HttpLambdaIntegration(
109
109
// create a new HTTP API with IAM as default authorizer
110
110
const httpApi = new HttpApi (apiStack , " HttpApi" , {
111
111
apiName: " myHttpApi" ,
112
- defaultAuthorizer: iamAuthorizer ,
113
112
corsPreflight: {
114
113
// Modify the CORS settings below to match your specific requirements
115
114
allowMethods: [
@@ -137,7 +136,15 @@ httpApi.addRoutes({
137
136
// add a proxy resource path to the API
138
137
httpApi .addRoutes ({
139
138
path: " /items/{proxy+}" ,
140
- methods: [HttpMethod .OPTIONS , HttpMethod .ANY ],
139
+ methods: [HttpMethod .ANY ],
140
+ integration: httpLambdaIntegration ,
141
+ authorizer: iamAuthorizer ,
142
+ });
143
+
144
+ // add the options method to the route
145
+ httpApi .addRoutes ({
146
+ path: " /items/{proxy+}" ,
147
+ methods: [HttpMethod .OPTIONS ],
141
148
integration: httpLambdaIntegration ,
142
149
});
143
150
@@ -155,8 +162,9 @@ const apiPolicy = new Policy(apiStack, "ApiPolicy", {
155
162
new PolicyStatement ({
156
163
actions: [" execute-api:Invoke" ],
157
164
resources: [
158
- ` ${httpApi .arnForExecuteApi (" items" )} ` ,
159
- ` ${httpApi .arnForExecuteApi (" cognito-auth-path" )} ` ,
165
+ ` ${httpApi .arnForExecuteApi (" *" , " /items" )} ` ,
166
+ ` ${httpApi .arnForExecuteApi (" *" , " /items/*" )} ` ,
167
+ ` ${httpApi .arnForExecuteApi (" *" , " /cognito-auth-path" )} ` ,
160
168
],
161
169
}),
162
170
],
0 commit comments