Anyone by chance happen to know how to get the fun...
# help
Anyone by chance happen to know how to get the functionArn of a route in the api construct? It used to work by doing Object.keys(api_variable.functions) in version 0.30.0 but something seems to have changed with the api construct where now I can use api_variable.routes, but that just returns “GET /“. Which the documentation seems to allow me to use api_variable.getFunction(“GET /“), and I thought I was out of the woods but that returns a function object that when I try to grab the property it resolves to this opaque ${Token[TOKEN.1056]} that I can’t seem to turn into anything related to an actual functionArn that AWS will understand?
The token you're getting is at build time. When that is sent to AWS they resolve the token to a real ARN (it doesn't exist at build time). You can pass that anywhere else in sst and it should work
can you share more about what you need to do with the ARN?
The way you have it is the right approach, using
api.getFunction("GET /")
Ah I see, it’s just odd because the 0.0.30 serverless actually resolved to a real functionArn during the execution of MyStack.js which successfully was passed to and used by functions later in the MyStack.js file
Example of how I used it before: let api_function_arns = []; let api_function_keys = Object.keys(api.functions); for (let i = 0; i < api_function_keys.length; i++) { api_function_arns.push(api.functions[api_function_keys[i]].functionArn); }
Then I would pass to a function I wanted to have access to it like so:
new sst.Function(this, “function”, { bundle: { nodeModules: [“saslprep”], }, handler: “src/utils.handler”, timeout: 30, environment: { stage: scope.stage, function_arns: JSON.stringify([ ...api_function_arns ]) } });
Have you tried that? I think it should work - I don't know exactly how AWS's token replacement works but it should theoretically support that
Yeah if I take the 0.0.30 code running in production and just upgrade it fails at build time because it cannot do Object.keys(api.functions) anymore
One sec I can run it right now and give a better answer
Having it as tokens works fine I’m an idiot sorry
For some reason I remember getting actual Arns even while executing the MyStack.js but I guess not
haha no worries, I was also confused when I first starting using cdk