hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.83k stars 449 forks source link

Cannot read property 'startsWith' of undefined #763

Closed dirien closed 3 years ago

dirien commented 3 years ago

Community Note

cdktf & Language Versions

cdktf 0.4.0 github.com/hashicorp/terraform-cdk-go/cdktf v0.4.0

Affected Resource(s)

All created resources

Debug Output

  ERROR  Cannot read property 'startsWith' of undefined

 /usr/local/Cellar/cdktf/0.4.0/libexec/lib/node_modules/cdktf-cli/bin/cmds/ui/components/resource-name.js:12:43

  9: exports.ResourceName = ({ name, stackName }) => {
 10:     const prettyName = name.replace(/(_[A-F\d]{8})$/, '');
 11:     let [resource, resourceName] = prettyName.split('.');
 12:     if (stackName != null && resourceName.startsWith(stackName)) {
 13:         const [, ...path] = resourceName.split('_');
 14:         resourceName = path.join('_');
 15:     }

Expected Behavior

Delete all the resources

Actual Behavior

Crash

Steps to Reproduce

Deploy a stack via terraform-go

Important Factoids

References

dirien commented 3 years ago

To continue, i delete the stack via terrafrom destroy in the cdktf.out folder. That worked perfectly fine.

The source code you can check under https://github.com/dirien/stackit-faasd/tree/main/faasd

skorfmann commented 3 years ago

I think this should be fixed by https://github.com/hashicorp/terraform-cdk/pull/761 - Could you please try cdktf-cli@next?

dirien commented 3 years ago

I use brew for the install of cdktf

brew install cdktf

skorfmann commented 3 years ago

Ok, no problem - we'll do a patch release today where this will be fixed for Homebrew as well. Gonna update this issue here, once it's released.

skorfmann commented 3 years ago

We released 0.4.1 earlier today - see #765 Please try again with that version.

dirien commented 3 years ago

hi @skorfmann, works like a charm now! Many thanks for your effort πŸ‘πŸ»

github-actions[bot] commented 1 year ago

I'm going to lock this issue 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 similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.