Replies: 1 comment 3 replies
-
Ended up with a solution that works but feel like quite ugly. app.arc
src/plugins/arc-plugin-http-provisioned-concurrency.js const HTTP_LAMBDA_SUFFIX = "HTTPLambda";
const PROVISIONED_CONCURRENCY = 3;
const SLS_API = "AWS::Serverless::HttpApi";
const SLS_FUNC = "AWS::Serverless::Function";
const SLS_STAGE_NAME = "live";
module.exports = {
deploy: {
start: async ({ arc, cloudformation, dryRun, inventory, stage }) => {
Object.keys(cloudformation.Resources).map((key) => {
const res = cloudformation.Resources[key];
switch (res.Type) {
case SLS_API: {
Object.keys(res.Properties.DefinitionBody.paths).map((path) => {
Object.keys(res.Properties.DefinitionBody.paths[path]).map((method) => {
const fnSub =
res.Properties.DefinitionBody.paths[path][method][
"x-amazon-apigateway-integration"
]["uri"]["Fn::Sub"];
if (typeof fnSub === "string") {
res.Properties.DefinitionBody.paths[path][method][
"x-amazon-apigateway-integration"
]["uri"]["Fn::Sub"] = res.Properties.DefinitionBody.paths[path][method][
"x-amazon-apigateway-integration"
]["uri"]["Fn::Sub"].replace(
"HTTPLambda.Arn}/invocations",
`HTTPLambda.Arn}:${SLS_STAGE_NAME}/invocations`
);
}
});
});
break;
}
case SLS_FUNC:
// Configure the provisioned concurrency if the Lambda handler is a HTTP handler.
if (key.endsWith(HTTP_LAMBDA_SUFFIX)) {
res.Properties.AutoPublishAlias = SLS_STAGE_NAME;
res.Properties.DeploymentPreference = {
Type: "AllAtOnce",
};
res.Properties.ProvisionedConcurrencyConfig = {
ProvisionedConcurrentExecutions: PROVISIONED_CONCURRENCY,
};
}
break;
}
});
return cloudformation;
},
},
}; |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Does anyone here know how to extend the Cloudformation template to support provisioned concurrency? What I have tried was
HttpLambda
Properties with the below:StageName: live
.However, the changes above just wouldn't integrate the API gateway's
live
stage correctly to the HttpLambdalive
version and show{ "message": "not found" }
. Is there any example we can refer to for enabling provisioned concurrency? Thanks.Note: I was following the approach recommended here.
Beta Was this translation helpful? Give feedback.
All reactions