Hi, I notice when I deploy my lambda function, sst...
# help
j
Hi, I notice when I deploy my lambda function, sst will format my lambda function name:
Copy code
const stackALambda = new sst.Function(this, 'DoSomething', {
      handler: 'path/to/doSomething.handler',
      runtime: lambda.Runtime.NODEJS_14_X,
    })
When run
sst start
, in my aws console, I saw a lambda function name 'my-project-DoSomethingdlsfinksd' . If I redeploy the lambda function name will change again. I have another lambda that will invoke this lambda function, how can I get the function name dynamically. In another lambda function(in another dedicated stack), I need to get the function name dynamically so I don't have to change the name whenever DoSomething update:
Copy code
await lambda
      .invoke({
        FunctionName: `DoSomething`, // <--  this will throw resource not found. how to get the formatted function name dynammically? 
        Payload: JSON.stringify({
          data: "data"
        }),
        InvocationType: 'RequestResponse',
      })
      .promise()
m
h
You could point to your lambda using arn which is always constant and unique
In your case it would be stackALambda.arn or something like that. I don't remember off the top of my head but autocomplete can help
Pass that Arn as an environment var to your calling lambda
j
Update: I end up using arn as environment var like what @Hamed Mamdoohi suggested. Thank a lot.