Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloudBackend: support environment variables like TF_CLOUD_ORGANIZATION #3586

Open
1 task done
gmeligio opened this issue Apr 14, 2024 · 2 comments
Open
1 task done
Labels
bug/has-workaround A bug with a workaround (may not be elegant) bug Something isn't working cdktf priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. terraform cloud

Comments

@gmeligio
Copy link
Contributor

Expected Behavior

I expected cdktf to follow the cloud block documentation

TF_CLOUD_ORGANIZATION - The name of the organization. Terraform reads this variable when organization omitted from the cloud block`. If both are specified, the configuration takes precedence.

Hopefully the other environment variables mentioned in those docs can be supported as well. The current list is:

Actual Behavior

It turns out that organization is a required prop for CloudBackend.

Property 'organization' is missing in type '{ workspaces: NamedCloudWorkspace; }' but required in type 'CloudBackendConfig'.ts(2345)

Steps to Reproduce

  1. Create a CloudBackend.
  2. Don't declare the prop organization.

Versions

cdktf debug
language: typescript
cdktf-cli: 0.20.6
node: v20.10.0
cdktf: 0.20.6
constructs: 10.3.0
jsii: null
terraform: 1.8.0
arch: x64
os: linux 6.5.0-27-generic
providers
@cdktf/provider-tfe (PREBUILT)
terraform provider version: 0.53.0
prebuilt provider version: 11.2.0
cdktf version: ^0.20.0

Providers

──────────┬────────────┬──────────────┬──────────────┬───────────┐
───── ────── ─── ──── ─────── ─────
Provider │ Provider │ CDKTF Constra│ Package Name │ Package │
Name Version int Version
──────────┼────────────┼──────────────┼──────────────┼───────────┤
───── ────── ─── ──── ─────── ─────
tfe │ 0.53.0 │ ^0.20 │ @cdktf/provid│ 11.2.0 │
.0 er-tfe
──────────┴────────────┴──────────────┴──────────────┴───────────┘
───── ────── ─── ──── ─────── ─────

Gist

No response

Possible Solutions

  1. Set fields that are supported to be passed as environment variables to optional in the TypeScript declaration.

Workarounds

  1. Set organization to "hardcoded-name-of-organization".

Anything Else?

No response

References

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
@gmeligio gmeligio added bug Something isn't working new Un-triaged issue labels Apr 14, 2024
@ansgarm
Copy link
Member

ansgarm commented Apr 15, 2024

Hi @gmeligio 👋

This probably stems from the times when the CDKTF CLI would create workspaces for you and thus required these to be set.

In the meantime you can use an override to empty the cloud block:

const stack = new MyStack(app, "test");
new CloudBackend(stack, {organization: "dummy", workspaces: new NamedCloudWorkspace("dummy")});
stack.addOverride("terraform.cloud", {organization: undefined, workspaces: undefined});

will result in:

// ...
"terraform": {
    "cloud": {
    }
  }
// ...

@ansgarm ansgarm added terraform cloud cdktf priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. bug/has-workaround A bug with a workaround (may not be elegant) and removed new Un-triaged issue labels Apr 15, 2024
@gmeligio
Copy link
Contributor Author

Hi @ansgarm . Thank you so much for providing a workaround! I'll use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/has-workaround A bug with a workaround (may not be elegant) bug Something isn't working cdktf priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. terraform cloud
Projects
None yet
Development

No branches or pull requests

2 participants