Python->Using Construct Libraries->Extra Credit bug
awsbenpeterson opened this issue · 3 comments
Describe the bug
When running cdk watch
the hotswap operation for the ViewHitCounterRendered function created by this construct library does not successfully deploy. However, when I run cdk deploy
without the --hotswap flag it is successful.
To be fair I'm not yet sure if this is a hotswap bug or a construct library bug, but in either situation it should be documented in the cdkworkshop unless this is a personal problem for just me.
Expected Behavior
I would expect the cdk deploy --hotswap
command to yield the same result as cdk deploy
but that is not the case.
Current Behavior
❌ cdk-workshop failed: InvalidParameterType: Expected params.Environment.Variables['TABLE_NAME'] to be a string
at ParamValidator.fail (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:50:37)
at ParamValidator.validateType (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:233:10)
at ParamValidator.validateString (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:155:32)
at ParamValidator.validateScalar (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:131:21)
at ParamValidator.validateMember (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:95:21)
at ParamValidator.validateMap (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:118:14)
at ParamValidator.validateMember (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:93:21)
at ParamValidator.validateStructure (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:76:14)
at ParamValidator.validateMember (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:89:21)
at ParamValidator.validateStructure (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-sdk/lib/param_validator.js:76:14) {
code: 'InvalidParameterType',
time: 2022-09-16T15:30:39.374Z
}
❌ Deployment failed: Error: Stack Deployments Failed: InvalidParameterType: Expected params.Environment.Variables['TABLE_NAME'] to be a string
at deployStacks (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-cdk/lib/deploy.ts:61:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at CdkToolkit.deploy (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:312:7)
at CdkToolkit.invokeDeployFromWatch (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:756:7)
at deployAndWatch (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:371:7)
at FSWatcher.<anonymous> (/local/home/benpte/.nvm/versions/node/v16.17.0/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:400:9)
Reproduction Steps
This code snippet from the cdk_workshop_stack.py file as described in the workshop produces the error when running cdk deploy --hotswap
and is successful when running cdk deploy
TableViewer(
self, 'ViewHitCounter',
title='Hello Hits',
table=hello_with_counter.table,
sort_by='-hits'
)
Possible Solution
No response
Additional Information/Context
I actually found this running cdk watch and then realized it is a hotswap error.
CDK CLI Version
2.41.0 (build 6ad48a3)
Section
No response
Browser
No response
Language
Python
It looks like this is a feature request that has since been closed:
"Since Function's environment update is not considered hotswappable, user can never perform a hotswap deployment with this code."
We can make a note of this limitation in the hotswap section of the workshop, at the bottom of this page. Thanks for reporting!