typescript
typescript copied to clipboard
Provisioned concurrency variable doesn't work with typescript
Instead of using serverless.yml files we use serverless.ts files since our code is written in typescript and we wanted to keep things consistent. However this has caused a problem with being able to dynamically set the number of provisioned concurrency on deployment. We need this functionality as we do not need as much, or any, provisioned concurrency in non-production but do need it for production. Below is a snippet of our index.ts file for our helloworld lambda using serverless framework.
import schema from "./schema";
import { handlerPath } from "@libs/handlerResolver";
export default {
handler: `${handlerPath(__dirname)}/handler.main`,
provisionedConcurrency: parseInt("${self:custom.envConfig.helloProvisionedMin}"),
events: [
{
http: {
method: "post",
path: "hello",
request: {
schemas: {
"application/json": schema,
},
},
},
},
],
};
We have tried multiple iterations, shown here.
provisionedConcurrency: "${self:custom.envConfig.helloProvisionedMin}", // DOESNT WORK, ERRORS WITH TYPE ERROR
provisionedConcurrency: parseInt("${self:custom.envConfig.helloProvisionedMin}"), // DOESNT WORK AS IT DOES NOT PROVISION ANY CONCURRENCY
provisionedConcurrency: 1, // WORKS
I also attempted to set this directly in the serverless.ts file, instead of using the index.ts for each function, but have not been able to get that working either. Being able to dynamically set provisioned concurrency based on the environment being deployed to should be possible. How would we be able to accomplish this?
We are on serverless version 3.24.1 and @serverless/typescript version 3.21.0.