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.8k stars 443 forks source link

`cdktf-cli`: `init` always using Terraform Cloud #2960

Closed lohrm-stabl closed 1 year ago

lohrm-stabl commented 1 year ago

Expected Behavior

Terraform cloud is not used when entering n when asked for the Terraform Cloud integration.

Actual Behavior

The web-browser opens to authenticate with Terraform Cloud.

This is the output, when entering 'n' when asked for TF cloud. I never entered 'Y', 'y', 'yes'.

❯ cdktf init
Welcome to CDK for Terraform!

By default, cdktf allows you to manage the state of your stacks using Terraform Cloud for free.
cdktf will request an API token for app.terraform.io using your browser.

If login is successful, cdktf will store the token in plain text in
the following file for use by subsequent Terraform commands:
    /home/michi/.terraform.d/credentials.tfrc.json

Note: The local storage mode isn't recommended for storing the state of your stacks.

? Do you want to continue with Terraform Cloud remote state management? yes

opening webpage using your browser.....

If the web browser didn't open the window automatically, you can go to the following url:
        https://app.terraform.io/app/settings/tokens?source=terraform-login

? Token for app.terraform.io 🔑

Or when piping n into cdktf:

❯ echo 'n' | cdktf init
Welcome to CDK for Terraform!

By default, cdktf allows you to manage the state of your stacks using Terraform Cloud for free.
cdktf will request an API token for app.terraform.io using your browser.

If login is successful, cdktf will store the token in plain text in
the following file for use by subsequent Terraform commands:
    /home/michi/.terraform.d/credentials.tfrc.json

Note: The local storage mode isn't recommended for storing the state of your stacks.

? Do you want to continue with Terraform Cloud remote state management? yes

opening webpage using your browser.....

If the web browser didn't open the window automatically, you can go to the following url:
        https://app.terraform.io/app/settings/tokens?source=terraform-login

? Token for app.terraform.io 🔑 %

Steps to Reproduce

  1. Install Terraform
  2. Run npm install cdktf-cli
  3. Run cdktf init
  4. When asked for TF cloud, enter `n
  5. Webbrowser opens anyways

Versions

language: null cdktf-cli: 0.17.0 node: v20.3.1 terraform: 1.5.1 arch: x64 os: linux 5.15.90.1-microsoft-standard-WSL2

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

Community Note

ansgarm commented 1 year ago

Hi @lohrm-stabl 👋

thank you for reporting this! I'll close this as it's a duplicate of https://github.com/hashicorp/terraform-cdk/issues/2952

github-actions[bot] commented 11 months 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.