I have this project structure (where control
is the name and root of my project):
control
|_ src
|_ control_loader -> this has a function inside called also control_loader
|_ utils
|_ some_helper_function.py
|_ __init__.py
|_ __init__.py
|_ lib
|_ some-cdk-where-i-declare-a-lambda.ts
|_ requirements.txt
Inside some-cdk-where-i-declare-a-lambda.ts
I have this (among all the other necessary stuff):
new Function(this, `${this.appName}${this.stageName}ControlLambdaLoader`, {
code: Code.fromAsset(path.join(__dirname, '../src'), {
bundling: {
image: Runtime.PYTHON_3_8.bundlingImage,
command: [
'bash', '-c',
'pip install -r requirements.txt -t /asset-output && cp -au . /asset-output',
],
},
}),
runtime: Runtime.PYTHON_3_8,
handler: 'control_loader.control_loader',
vpc,
vpcSubnets: vpc.selectSubnets({
subnetType: SubnetType.PRIVATE_WITH_NAT,
}),
});
However, upon running cdk synth
, I get the following:
(venv) PS C:\Users\rodri\Documents\control> cdk synth
npx: installed 15 in 1.145s
Bundling asset controlPipelineStack/controlBetaDeployStage/controlbetaStack/controlbeta/controlbetaControlLambdaLoader/Code/Stage...
Failed to bundle asset controlPipelineStack/controlBetaDeployStage/controlbetaStack/controlbeta/controlbetaControlLambdaLoader/Code/Stage, bundle output is located at C:\Users\rodri\Documents\control\cdk.out\asset.059c3b383943a1fadd3d933b670a7d351991e742d24a9785474b35c846267fde-error: Error: spawnSync docker EN
OENT
This is a very cryptic error. I know the bundling is done by docker to push the dependencies as a zip asset, but, any idea of where is this failing? I also tried to change the location of requirements.txt
to inside src
and that didn't help. I can deploy everything I remove the Lambda out. What am I doing wrong? Also, how do I make the bundle include some_helper_function.py
as well?
Thanks!
privileged: true
. It's also not enough perhaps to enable this, but you when you do, also remove at first the lambda function requiring bundling from the build step. Then, let me pipeline mutate itself to make it privileged, then push back the lambda, and it could work. – Paniculatedocker
installed. – Taiwan