Ivan Roskoshnyi
04/05/2022, 3:50 PMconfig
where we have to hardcode lambda”s name. But the issue is I use serverless stack stages (dev/prod) and all lambdas have unique hash suffix. I don’t know if this is a good idea if I search for a specific lambda and use a condition smth like:
if (env === 'prod') {
return 'prod-lambda-adah32h34'
} else {
return 'dev-lambda-asdh3424jh'
}
thdxr
04/05/2022, 3:54 PMthdxr
04/05/2022, 3:54 PMenvironment: {
LAMBDA_TO_CALL: func.functionArn
}
Ivan Roskoshnyi
04/05/2022, 5:36 PMconst COUNTRIES_LAMBDA = apiStack.api.getFunction('GET /settings/country-setup')?.functionName
if (COUNTRIES_LAMBDA) {
app.addDefaultFunctionEnv({
COUNTRIES_LAMBDA
})
}
but the output of this looks like: `${Token[TOKEN.680]}`and not like: stage-projectName-lambdaName
thdxr
04/05/2022, 5:37 PMthdxr
04/05/2022, 5:37 PMIvan Roskoshnyi
04/05/2022, 5:50 PMaddDefaultFunctionPermissions
, addDefaultFunctionEnv
, and addDefaultFunctionLayers
to progressively add more permissions, environment variables, and layers to the defaults. These can be called multiple times and from anywhere.
However, they only affect the functions that are created after the call.
-----
but the issue is I need the name of a lambda in the scope of one stack. This lambda is a “sibling” of another oneIvan Roskoshnyi
04/05/2022, 5:52 PMsst app
from the lambda or….another way how to extract lambda”s name in the scope of one API STACK?
Or…split the stacks somehow so I can run API stack where my function is located, then I can add env var
and after then add another lambda which can read this var
?Ross Coundon
04/05/2022, 6:01 PMthdxr
04/05/2022, 6:03 PMIvan Roskoshnyi
04/05/2022, 6:12 PMIvan Roskoshnyi
04/05/2022, 6:13 PMthdxr
04/05/2022, 6:14 PMthdxr
04/05/2022, 6:14 PMthdxr
04/05/2022, 6:14 PMthdxr
04/05/2022, 6:15 PMapi.getFunction("func1").addEnvironment(api.getFunction("func2"))
Ivan Roskoshnyi
04/05/2022, 6:17 PMOh you're saying you have 2 lambda functions in the same api and one needs to know baout the other?
- correct.
So…it is not a good idea and it is better to extract my code?thdxr
04/05/2022, 6:20 PMRoss Coundon
04/05/2022, 6:22 PMIvan Roskoshnyi
04/05/2022, 6:31 PMRoss Coundon
04/05/2022, 6:33 PMIvan Roskoshnyi
04/05/2022, 6:34 PMIvan Roskoshnyi
04/05/2022, 7:14 PMapi.getFunction("func1").addEnvironment(api.getFunction("func2"))