Skip to content

(hotswap): Hotswap always deploys all resources changed since last full deployment #885

@comcalvi

Description

@comcalvi

Running cdk deploy --hotswap will update all hotswapped resources since the last CloudFormation deployment.

Suppose a stack contains two lambda functions, lambda1 and lambda2. Then a change to lambda1 is deployed with --hotswap. Now a change to lambda2 is made. When these changes to lambda2 are deployed with --hotswap, the changes to lambda1 are also deployed, even though they were deployed by a previous hotswap.

This happens because all potentially hotswappable changes are found by diffing the current app template with the template in CloudFormation, which is not updated by hotswaps. Thus subsequent --hotswap deployments do not know about previous --hotswap deployments; that is, hotswaps are not aware of drift introduced by previous hotswaps.

This could incur a performance penalty over time. The time it takes for a --hotswap deployment to complete is proportional to the number of changed resources, not the number of changes. If many resources are changed over the course of many --hotswap deployments, then the performance will degrade. If many changes are made to only a few resources, the performance change is negligible.

To avoid this performance loss, perform a regular deployment. This will remove all drift, meaning that the next hotswap will not suffer the performance penalty from the previously accumulated drift.

Edit by @mrgrain

#888 poses a related problem. When reverting back to the original template after a change that was hotswapped, hotswap does not recognise this as a change anymore and therefore will not run.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions