Hello! I have a question that I cant seem to figur...
# help
e
Hello! I have a question that I cant seem to figure out on my own, so maybe you guys can point me in the right direction: We currently are using SST to build a API, and we are now trying to do ProvisionedConcurency - sadly the way the docs show how to do it does not seem to give the desired result: Here is what I tried: I defined my route inside the api gateway, and added provisionedConcurrency to the currentVersion property. I then use the fn.currentVersion to trigger a new Lambda version - this works, I have a new version everytime I deploy. But the configured provised concurency is not set on AWS CONSOLE. And looking at the logs, we still get a cold start on our lambda in the first invokation. I then tried to create a ALIAS to the function
Copy code
if (route === ApiRoutes.RouterPath) {
        const version = fn.currentVersion;
        version.addAlias("AUTO_GENERATE_ALIAS", {
          provisionedConcurrentExecutions: 1,
        });
      }
This does in fact create the alias with the concurency setup correctly in the AWS CONSOLE. THe problem now, is that we need to manually go the AWS console and then point the gateway to this alias manually, and press DEPLOY for it to actually start hitting our alias instead of LATEST$. Am I missing a step somwhere? How can I create this without the need to have a manual step?
d
I have not implemented provisioned concurrency yet, but as I was reading your question, I thought “It can’t possibly be this bad of an interface”. Turns out I was wrong, and you seem to be on the right track. I really don’t see anything wrong with your code, but I am wondering about this feature flag maybe causing issues for you? Might be worth just turning on anyway.
e
Thats a good lead! I will see if this makes a difference
f
@Eduardo I just trying setting the provisioned concurrency as suggested in the doc, and it seems to have worked for me.
If you git clone > yarn install > yarn sst deploy, and then check the console, u should see provisioned concurrency set to
5
.
d
what doc is this, @Frank? I only found things like Edurdo.
f
Not an in-depth doc haha
d
wow…why dont they use that in their examples? class Function (construct) · AWS CDK (amazon.com) how weird…
f
not sure about this specific case, but a lot of CDK’s doc/implementation are community contributed.. and I’ve seen examples in their doc that are very specific to the implementer’s use case, not necessarily a generic example
e
Hi, I have been on holiday, I will give this a try a bit later today, but when I tried it didnt work for sure. I will get back to you once I tested. Thank you for the time you took!
For some reason I cant get this work on my setup:
Copy code
[ApiRoutes.RouterPath]: {
          function: "src/lambdas/router.handler",
          currentVersionOptions: {
            provisionedConcurrentExecutions: 5,
          },
        },
      },
    });
    //@ts-ignore
    // eslint-disable-next-line @typescript-eslint/no-unused-expressions
    this.api.getFunction(ApiRoutes.RouterPath).currentVersion;
I have a new function version, but if I go to that version an check provisioned concurrency Its empty. I going to see if I can find the difs between yours and mine.
Quick update this works...
Copy code
defaultFunctionProps: {
        timeout: 120,
        currentVersionOptions: {
          provisionedConcurrentExecutions: 3,
        },
It looks like if you have defaultFunctionProps, then it the rest is not picked up.