Sam Hulick
09/21/2021, 6:09 PMapp.setDefaultFunctionProps({
layers: [
lambda.LayerVersion.fromLayerVersionArn(
this,
'KnexLayer',
process.env.KNEX_LAYER_ARN
),
],
});
of course, you can no longer call this method more than once. the problem is, if I try to move this into the main index.ts and add it to that setDefaultFunctionProps
call, I get:
Error: Import at 'KnexLayer' should be created in the scope of a Stack, but no Stack found
how do I solve this?
setDefaultFunctionProps
nowthis.setDefaultFunctionProps
in the stack, I get:
Error: Default function props for the stack must be set before any resources have been added. Use 'addDefaultFunctionEnv' or 'addDefaultFunctionPermissions' instead to add more default properties.
this is a bit confusing. this is literally before any resource gets created, it’s the first stack that gets set upthdxr
09/21/2021, 6:23 PMthdxr
09/21/2021, 6:23 PMapp.setDefaultFunctionProps(stack =>
thdxr
09/21/2021, 6:23 PMSam Hulick
09/21/2021, 6:24 PMthdxr
09/21/2021, 6:24 PMSam Hulick
09/21/2021, 6:24 PMthdxr
09/21/2021, 6:24 PMstack => {
layers: [
lambda.LayerVersion.fromLayerVersionArn(
stack,
'KnexLayer',
process.env.KNEX_LAYER_ARN
),
],
}
thdxr
09/21/2021, 6:24 PMSam Hulick
09/21/2021, 6:24 PMthdxr
09/21/2021, 6:24 PMSam Hulick
09/21/2021, 6:24 PMthdxr
09/21/2021, 6:25 PMthdxr
09/21/2021, 6:26 PMapp.addDefaultFunctionLayers([...])
in the next release so that you can import the layer once in a stack and add it as a default. This is probably more useful for layers you need to build yourself (eg prisma)Sam Hulick
09/21/2021, 6:26 PMthdxr
09/21/2021, 6:26 PMSam Hulick
09/21/2021, 6:27 PMSam Hulick
09/21/2021, 6:29 PMSam Hulick
09/21/2021, 6:37 PMthdxr
09/21/2021, 6:38 PMthdxr
09/21/2021, 6:38 PMSam Hulick
09/21/2021, 6:38 PMSam Hulick
09/21/2021, 6:38 PM