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.85k stars 450 forks source link

provider add: provider with resource named "version" fails #3664

Closed jsok closed 2 months ago

jsok commented 3 months ago

Expected Behavior

Adding a provider like cdktf provider add "spacelift-io/spacelift" should work.

Actual Behavior

> npx cdktf provider add "spacelift-io/spacelift"
[2024-07-02T13:36:44.038] [INFO] default - Checking whether pre-built provider exists for the following constraints:
  provider: spacelift-io/spacelift
  version : latest
  language: go
  cdktf   : 0.20.8

[2024-07-02T13:36:44.250] [INFO] default - Pre-built provider does not exist for the given constraints.
[2024-07-02T13:36:44.250] [INFO] default - Adding local provider registry.terraform.io/spacelift-io/spacelift with version constraint undefined to cdktf.json
Local providers have been updated. Running cdktf get to update...
⠹ downloading and generating modules and providers...
[2024-07-02T13:36:54.662] [ERROR] default - [jsii-pacmak] [WARN] go failed

[jsii-pacmak] [WARN] go failed
[2024-07-02T13:36:54.702] [ERROR] default - Error: EISDIR: illegal operation on a directory, open '/private/var/folders/f7/0rddcnrn4mdc8xxxrk_56z_c0000gp/T/cdktf.ta33Kq/dist/go/spacelift/version'

Error: non-zero exit code 1
    at ChildProcess.<anonymous> (/Users/jsok/.asdf/installs/nodejs/20.15.0/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:96:51560)
    at Object.onceWrapper (node:events:634:26)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess.emit (node:domain:488:12)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:519:28)
    at Socket.emit (node:domain:488:12)
    at Pipe.<anonymous> (node:net:338:12) {
  stderr: '[jsii-pacmak] [WARN] go failed\n' +
    "Error: EISDIR: illegal operation on a directory, open '/private/var/folders/f7/0rddcnrn4mdc8xxxrk_56z_c0000gp/T/cdktf.ta33Kq/dist/go/spacelift/version'\n"
}
⠧ downloading and generating modules and providers...
Error: non-zero exit code 1

Steps to Reproduce

  1. cdktf init --template go
  2. cdktf provider add "spacelift-io/spacelift"

Versions

language: go cdktf-cli: 0.20.8 cdktf: 0.20.8 node: 20.15.0

Providers

┌────────────────────────┬──────────────────┬───────┬────────────┬──────────────┬─────────────────┐
│ Provider Name          │ Provider Version │ CDKTF │ Constraint │ Package Name │ Package Version │
├────────────────────────┼──────────────────┼───────┼────────────┼──────────────┼─────────────────┤
│ spacelift-io/spacelift │                  │       │ ~> 1.14    │              │                 │
└────────────────────────┴──────────────────┴───────┴────────────┴──────────────┴─────────────────┘

Gist

No response

Possible Solutions

It seems that the resource https://registry.terraform.io/providers/spacelift-io/spacelift/latest/docs/resources/version is some kind of reserved word in cdktf?

Workarounds

A hack workaround is to simply remove the version symbol from the exports, e.g.

> ag version *.ts
index.ts
39://export * as version from './version';

lazy-index.ts
39://Object.defineProperty(exports, 'version', { get: function () { return require('./version'); } });

Anything Else?

No response

References

No response

Help Wanted

Community Note

jsok commented 2 months ago

Much appreciated @ansgarm !

github-actions[bot] commented 1 month 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.