I'm using CDK in python to deploy a Lambda function
from aws_cdk import (
core,
aws_lambda as _lambda
)
class MyLambdaStack(core.Stack):
def __init__(self, id, scope: core.Construct, **kwargs) -> None:
super().__init__(id, scope, **kwargs)
my_function = _lambda.Function(self, "MyLambda",
runtime=_lambda.Runtime.PYTHON_3_8,
handler="MyLambda.handler",
code=_lambda.Code.from_asset(
'./lambda',
bundling=core.BundlingOptions(
image=_lambda.Runtime.PYTHON_3_8.bundling_docker_image,
command=[
'bash', '-c', 'pip install -r requirements.txt -t /asset-output && cp -au . /asset-output'
],
)
)
)
The bundling works fine, however every time I run a cdk command, the docker image gets spun up and the pip install command runs.
Even a cdk ls causes the bundle to run.
How can I prevent this from running during every cdk command?