I have two lambda in cdk file.
With this source code cdk deploy
do the first deployment, and after that,
Everytime do cdk deploy
the new two lambda code are deployed.
However is it possible to deploy only one lambda?
What is the best practice for this case?
const msgLambda = new lambda.DockerImageFunction(this, "firstLambda", {
functionName: `sg-mg-lm`,
code: lambda.DockerImageCode.fromImageAsset(
"first",
{
"file": "Dockerfile.first"
}
),
environment:{
}
});
const wkLambda = new lambda.DockerImageFunction(this, "secondLambda", {
functionName: `sg-wk-lm`,
code: lambda.DockerImageCode.fromImageAsset(
"second",
{
"file": "Dockerfile.second"
}
),
environment:{
}
});
CodePudding user response:
cdk deploy
operates at the stack level, not at the resource level. If the two lambda functions have their own lifecycle, then you should have one stack for each.
As mentioned in the documentation:
Many CDK Toolkit commands (for example, cdk deploy) work on stacks defined in your app. If your app contains only one stack, the CDK Toolkit assumes you mean that one if you don't specify a stack explicitly
with two stacks, let's say Stack1
and Stack2
, you can then choose which one to deploy with:
$ cdk deploy Stack1
or
$ cdk deploy Stack2
and even both at the same time:
$ cdk deploy Stack1 Stack2