terraform-cdk
terraform-cdk copied to clipboard
feat(cli): Automatically Update Locked Providers
Fixes #1863
When locked providers aren't compatible with currently specified providers, automatically update the locked version. Users are likely to run into this situation when updating a pre-built provider package.
Still todo:
- Unit tests
- TFC checking
- Possibly exposing behavior as an option
@jsteinich is attempting to deploy a commit to the HashiCorp Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated |
---|---|---|---|---|
terraform-cdk-redirects | ❌ Failed (Inspect) | Oct 5, 2022 at 9:44AM (UTC) |
I'm a bit torn on whether an update to disable the auto upgrade is needed. From a developer perspective it seems unnecessary as you already went through the effort to upgrade the provider package; hence signally a desire to upgrade. I can imagine some organization wanting even tighter control, but that could be contrived. @ansgarm @DanielMSchmidt any thoughts?
@jsteinich I think it's fine to delete it. We are even thinking in the direction of generating it from the provider bindings used: https://github.com/hashicorp/terraform-cdk/issues/2200
I'm picking up work on the overarching cdktf provider update
command (#1745), just so you know :)
I'm leaning more towards providing an option to disable the automatic lock file update. I think it makes sense as a value in cdktf.json
rather than a cli option for every command; however, the current pattern would require passing the value through every command. Just reading cdktf.json
at a later point could be viable. Could also just generally pass the contents through every command as a single argument.
I don't believe this actually works
in my package.json I had
"dependencies": {
"@cdktf/provider-aws": "^9.0.0",
"@cdktf/provider-null": "^2.0",
"cdktf": "^0.12.0",
I upgraded my cdktf-cli to 14.3. I ran npm uninstall cdktf
(because if I don't i also run into more issues). Update my package.json to have
"dependencies": {
"@cdktf/provider-aws": "^9.0.0",
"@cdktf/provider-null": "^2.0",
**"cdktf": "^0.14.3",**
Ran npm i
Now at this point I expect to be able to run cdktf provider upgrade aws,null
and have it update my packages and my cdktf.json for me. But instead this breaks with
λ cdktf provider upgrade null
[2022-12-09T13:18:12.427] [ERROR] default - npm ERR! code ELSPROBLEMS
npm ERR! code ELSPROBLEMS
[2022-12-09T13:18:12.429] [ERROR] default - npm ERR! invalid: [email protected] /$redacted/cdktf/aws/ec2-stack/node_modules/cdktf
{
"error": {
"code": "ELSPROBLEMS",
"summary": "invalid: [email protected] /$redacted/cdktf/aws/ec2-stack/node_modules/cdktf",
"detail": ""
}
}
npm ERR! A complete log of this run can be found in:
npm ERR! /$redacted/.npm/_logs/2022-12-09T21_18_12_286Z-debug-0.log
npm ERR! invalid: [email protected] `$redacted/cdktf/aws/ec2-stack/node_modules/cdktf
{
"error": {
"code": "ELSPROBLEMS",
"summary": "invalid: [email protected] $redacted/cdktf/aws/ec2-stack/node_modules/cdktf",
"detail": ""
}
}
npm ERR! A complete log of this run can be found in:
npm ERR! /$redacted/.npm/_logs/2022-12-09T21_18_12_286Z-debug-0.log
Error: External Error: Could not determine CDKTF version. Please make sure you are in a directory containing a CDKTF project and have all dependencies installed.
at Object.External (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:94:41856)
at Object.ZFr (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:492:29211)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async qp.handleCommand (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cdktf.js:54:479)
at async B.handler (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cdktf.js:53:29879)
Collecting Debug Information...
/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^
Error: External Error: Could not determine CDKTF version. Please make sure you are in a directory containing a CDKTF project and have all dependencies installed.
at Object.External (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:94:41856)
at Object.ZFr (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:492:29211)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async qp.handleCommand (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cdktf.js:54:479)
at async B.handler (/opt/homebrew/Cellar/cdktf/0.14.3/libexec/lib/node_modules/cdktf-cli/bundle/bin/cdktf.js:53:29879) {
__type: 'External'
}
Node.js v18.12.1
The only way to actually upgrade is to go in, npm uninstall all my providers and then run cdktf provider add
This is the most cumbersome way to upgrade in (there's almost 5 steps) no way streamlined at all. Am I missing something?
@jin-ahn I copied your feedback to a new issue (#2437) so that it doesn't get lost.
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.