Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(cli): unable to hotswap when adding tags to lambda function #21556

Closed
ghost opened this issue Aug 11, 2022 · 5 comments
Closed

(cli): unable to hotswap when adding tags to lambda function #21556

ghost opened this issue Aug 11, 2022 · 5 comments
Assignees
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@ghost
Copy link

ghost commented Aug 11, 2022

Describe the bug

The CDK crashes when attempting to add tags to a lambda function while using hotswap.

Expected Behavior

The tags are added to the lambda function.

Current Behavior

 ❌  TestStack failed: TypeError: Cannot read properties of undefined (reading 'forEach')
    at isLambdaFunctionCodeOnlyChange (/Users/test/node_modules/aws-cdk/lib/api/hotswap/lambda-functions.ts:169:32)
    at isHotswappableLambdaFunctionChange (/Users/test/node_modules/aws-cdk/lib/api/hotswap/lambda-functions.ts:34:34)
    at findAllHotswappableChanges (/Users/test/node_modules/aws-cdk/lib/api/hotswap-deployments.ts:96:9)
    at tryHotswapDeployment (/Users/test/node_modules/aws-cdk/lib/api/hotswap-deployments.ts:50:37)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at deployStack (/Users/test/node_modules/aws-cdk/lib/api/deploy-stack.ts:274:39)
    at CdkToolkit.deploy (/Users/test/node_modules/aws-cdk/lib/cdk-toolkit.ts:210:24)
    at initCommandLine (/Users/test/node_modules/aws-cdk/lib/cli.ts:346:12)

Cannot read properties of undefined (reading 'forEach')

Reproduction Steps

  • Create lambda function, deploy stack
const func = new lambda.Function(this, "Function", {
  code: lambda.Code.fromInline(`exports.handler = async () => {}`),
  handler: "index.handler",
  runtime: lambda.Runtime.NODEJS_16_X,
});
  • Add tags, deploy stack
Tags.of(func).add("key", "value");

cdk deploy --hotswap

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.37.1

Framework Version

No response

Node.js Version

16.16.0

OS

Mac OS

Language

Typescript

Language Version

3.9.7

Other information

No response

@ghost ghost added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 11, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Aug 11, 2022
@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 2, 2022
@rix0rrr rix0rrr removed their assignment Sep 2, 2022
@comcalvi comcalvi self-assigned this Dec 6, 2022
@comcalvi
Copy link
Contributor

yep, this is bad. It turns out that hotswapping tags is entirely broken, and they can't be updated in any way today through hotswap (creating / destroying the Tags prop completely causes this crash, and doing additions / deletions of tags that already have a Tags prop causes a full deployment).

Question: Why do you need to hotswap tags? Why is this something that needs to be done each iteration cycle?

@ghost
Copy link
Author

ghost commented Dec 13, 2022

In our team we hotswap by default whenever deploying locally; if we have made changes that can't be hotswapped then we bank on the fact that a full deployment will be done even though the --hotswap argument was included.

If tags cannot be hotswapped, then could it fall back to a full deployment?

@comcalvi
Copy link
Contributor

falling back to a full deployment is the intended behavior. There seems to be no use case for the tags themselves to need to be hotswapped, so we're considering removing the Tag hotswap ability (it doesn't work anyway) and ignoring non-hotswappable property updates in a new flag.

skorfmann added a commit to cloudspec-dev/cloudspec that referenced this issue Dec 21, 2022
mergify bot pushed a commit that referenced this issue Feb 8, 2023
…fall back if necessary (#23653)

Changes the behavior of `--hotswap` to ignore all non-hotswappable changes and hotswap what it can. This works at two levels: changes to non-hotswappable resources are ignored, as well as non-hotswappable changes to hotswappable resources (eg `Tags` on a Lambda Function).

In addition, non-hotswappable changes are now logged; the logical ID, rejected changes, resource type, and reason why the changes were rejected are all provided for each non-hotswappable change.

At some point, support for tags of lambda functions was added. This either broke or simply never worked, and so this PR removes all logic to handle Tags.

The existing behavior of `--hotswap` can be used in `--hotswap-fallback`. It is preserved and unmodified by this change.

Closes #22784, #21773, #21556, #23640.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@comcalvi
Copy link
Contributor

closed by #23653

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

2 participants