terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

Can't use remote template on private repo

Open Zman94 opened this issue 8 months ago • 3 comments

Expected Behavior

cdktf init --template= should allow more methods to use a remote template including a local path.

Actual Behavior

cdktf init --template requires a zip file which, I presume, uses curl or wget under the hood to pull. This prevents users from using repositories that they have access to, but can't authenticate with using curl or wget

Steps to Reproduce

  • Fork python poetry remote template.
  • make the repo private
  • Create a release
  • cdktf init --template='<path to release' --local
  • Observe the following error
Extracting zip file
Error: end of central directory record signature not found
    at /usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:110:448419
    at /usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:110:456137
    at /usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:110:438097
    at FSReqCallback.wrapper [as oncomplete] (node:fs:682:5)

Versions

cdktf debug language: null cdktf-cli: 0.17.1 node: v18.16.0 terraform: 1.4.6 arch: x64 os: linux 6.2.0-1016-azure

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

  • [ ] I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Zman94 avatar Dec 01 '23 15:12 Zman94

Additional info: The line that would need to change to support a local ref is here https://github.com/hashicorp/terraform-cdk/blob/49558e5435c7858851eb102dddc788f8d4b6e640/packages/cdktf-cli/src/bin/cmds/helper/init.ts#L464.

Also, when I wget my file, I get an html page directing me to a single sign on.

Zman94 avatar Dec 01 '23 16:12 Zman94

I understand when you write <path to release> that it would refer to something like ../my-cloned-dir/ which is not the intended usage. Instead you should be using an URL to the GitHub repo, e.g. https://github.com/<user or organization>/<repo>/archive/refs/heads/main.zip. If you would want local files to work that would change the interface. You could create a for that PR if you like :)

DanielMSchmidt avatar Dec 08 '23 10:12 DanielMSchmidt

Is there guidance to running this with a private repo or an enterprise repo? There's no authentication that I could find in the code, so I was only ever able to download an HTML file pointing to a single sign on page

Zman94 avatar Dec 08 '23 14:12 Zman94