You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-17
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,6 @@
14
14
-[x]**Custom Domain + SSL** - Auto-configure a custom domain w/ a free AWS ACM SSL certificate.
15
15
-[x]**Team Collaboration** - Collaborate with your teamates with shared state and outputs.
16
16
-[x]**Built-in Monitoring** - Monitor your express app right from the Serverless Dashboard.
17
-
-[x]**(NEW) Auto-Generate An OpenAPI Spec On Each Deployment** - A new OpenAPI spec is generated after each deployment.
18
17
19
18
<br/>
20
19
@@ -115,7 +114,6 @@ inputs:
115
114
- arn:aws:second:layer
116
115
domain: api.serverless.com # (optional) if the domain was registered via AWS Route53 on the account you are deploying to, it will automatically be set-up with your Express app's API Gateway, as well as a free AWS ACM SSL Cert.
117
116
region: us-east-2 # (optional) aws region to deploy to. default is us-east-1.
118
-
openApi: true # (optional) (experimental) Initialize the express app on each deployment, extract an OpenAPI V.3 specification, and add it to the outputs.
119
117
```
120
118
121
119
Once you've chosen your configuration, run `serverless deploy` again (or simply just `serverless`) to deploy your changes.
@@ -221,21 +219,6 @@ If things aren't working, revert your code to the old code, remove the `traffic`
221
219
222
220
If things are working, keep the new code, remove the `traffic` configuration option, and deploy.
223
221
224
-
### Auto-Generate An OpenAPI V3 Specification From Your Express.js App
225
-
226
-
Version 1.5.0 introduced experimental support for auto-generating an OpenAPI specification from your Express app upon every deployment, then adding them to the `outputs` of your app.
227
-
228
-
This works by attempting to run your application on each deployment and extracting the routes you've defined in your Express app.
229
-
230
-
Currently, this feature is disabled by default, since it's experimental. To enable it, add `openApi: true` to your `serverless.yml` and ensure you are using the latest version of the Express coponent (>= 1.1.0).
231
-
232
-
Given a lot of things can happen in your application upon starting it up, this does not work consistently. For example, your environment variables will NOT be available during this process, which could cause your app not to initialize.
233
-
234
-
If it runs into an error trying to start your application, it will try its best to pass through useful errors to you so you can address what's blocking it from working. You can see these by running `serverless deploy --debug`
235
-
236
-
Overall, an OpenAPI specification generated by default is very powerful. This means you don't have to maintain that manually since it auto-updates on every deployment. (That's what serverless is all about!)
237
-
238
-
We will be adding many interesting features built on this. Extracting your endpoints and putting them into a common format was merely the first step...
error.message=`OpenAPI auto-generation failed due to the Express Component not being able to start your app. To fix this, you can turn this feature off by specifying "inputs.openApi: false" or fix the following issue: ${msg}`;
error.message=`OpenAPI auto-generation failed due to the Express Component not being able to start your app. To fix this, you can turn this feature off by specifying "inputs.openApi: false" or fix the following issue: ${msg}`;
// error.message = `OpenAPI auto-generation failed due to the Express Component not being able to start your app. To fix this, you can turn this feature off by specifying 'inputs.openApi: false' or fix the following issue: ${msg}`;
// error.message = `OpenAPI auto-generation failed due to the Express Component not being able to start your app. To fix this, you can turn this feature off by specifying 'inputs.openApi: false' or fix the following issue: ${msg}`;
164
+
// throw error;
165
+
// }
166
+
// };
160
167
161
168
/*
169
+
* DEPRECATED: This runs untrusted code and should not be used until we can find a way to do this more securely.
170
+
*
162
171
* Generate an OpenAPI specification from the Application
163
172
*
164
173
* @param ${object} instance - the component instance
console.log(`Unable to create AWS Lambda due to: ${e.message}`);
317
+
318
+
// Handle known errors
319
+
320
+
if(e.message.includes('The role defined for the function cannot be assumed by Lambda')){
321
+
// This error can happen upon first creation. So sleeping is an acceptable solution. This code will retry multiple times.
322
+
if(retries>5){
323
+
console.log(
324
+
'Attempted to retry Lambda creation 5 times, but the invalid role error persists. Aborting...'
325
+
);
326
+
327
+
// Throw different errors, depending on whether the user is using a custom role
328
+
if(instance.state.userRoleArn){
329
+
thrownewError(
330
+
'Unable to create the AWS Lambda function which your Express.js app runs on. The reason is "the role defined for the function cannot be assumed by Lambda". This might be due to a missing or invalid "Trust Relationship" within the policy of the custom IAM Role you you are attempting to use. Try modifying that. If that doesn\'t work, this is an issue with AWS Lambda\'s APIs. We suggest trying to remove this instance by running "serverless remove" then redeploying to get around this.'
331
+
);
332
+
}else{
333
+
thrownewError(
334
+
'Unable to create the AWS Lambda function which your Express.js app runs on. The reason is "the role defined for the function cannot be assumed by Lambda". This is an issue with AWS Lambda\'s APIs. We suggest trying to remove this instance by running "serverless remove" then redeploying to get around this. This seems to be the only way users have gotten past this.'
335
+
);
336
+
}
337
+
}
338
+
}
339
+
305
340
if(
306
-
e.message.includes('The role defined for the function cannot be assumed by Lambda')||
307
341
e.message.includes(
308
342
'Lambda was unable to configure access to your environment variables because the KMS key is invalid'
309
343
)
310
344
){
311
-
// we need to wait around 2 seconds after the role is created before it can be assumed
312
-
awaitsleep(2000);
313
-
returncreateLambda(instance,inputs,clients);
345
+
// This error can happen upon first creation. So sleeping is an acceptable solution. This code will retry multiple times.
346
+
if(retries>5){
347
+
console.log(
348
+
'Attempted to retry Lambda creation 5 times, but the KMS error persists Aborting...'
349
+
);
350
+
thrownewError(
351
+
'Unable to create the AWS Lambda function which your Express.js app runs on. The reason is "Lambda was unable to configure access to your environment variables because the KMS key is invalid". This is a known issue with AWS Lambda\'s APIs, and there is nothing the Serverless Framework can do to help with it at this time. We suggest trying to remove this instance by running "serverless remove" then redeploying to attempt to get around this.'
0 commit comments