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

Generate Winglang bindings for arbitrary Terraform providers #4922

Open
Chriscbr opened this issue Nov 13, 2023 · 3 comments
Open

Generate Winglang bindings for arbitrary Terraform providers #4922

Chriscbr opened this issue Nov 13, 2023 · 3 comments
Labels
🐶 dogfood Discovered while dogfooding Winglang ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🎨 sdk SDK

Comments

@Chriscbr
Copy link
Contributor

Chriscbr commented Nov 13, 2023

Feature Spec

As a user, I'd like a way to generate Wing bindings for any of the 3500+ Terraform providers so I can use any Terraform resource in my preflight code with type safety, autocompletion, and other goodness. This is similar to the facility provided by CDKTF (docs) for generating bindings in TypeScript, Python, and other languages.

For example, I might be able to run a command:

wing generate --tf pagerduty@~> 1.2

and then a .gen/pagerduty/ folder would be generated in my current project, with the bindings inside.

Then in my Wing application or library I can natively use the bindings like so:

bring "./gen/pagerduty" as pagerduty;

new pagerduty.schedule.Schedule();

Use Cases

Using Terraform providers that do not have publicly available bindings. The Terarform team only maintains bindings for a few dozen of the most popular Terraform providers like https://www.npmjs.com/package/@cdktf/provider-aws (these can be natively used in Wing since the npm packages include JSII metadata inside them).

Implementation Notes

It should be possible to generate the CDKTF bindings for TypeScript programmatically. Here's a script that generates TypeScript bindings for the kislerdm/neon provider inside a .gen directory.

import { ConstructsMaker } from "@cdktf/provider-generator";
import { Language } from "@cdktf/commons";

async function main() {
  const constructsMaker = new ConstructsMaker({
    targetLanguage: Language.TYPESCRIPT,
    codeMakerOutput: ".gen/",
  });
  await constructsMaker.generate([{
    name: "neon",
    fqn: "neon",
    version: '~> 0.2',
    source: 'kislerdm/neon',
    namespace: 'kislerdm',
  }]);
}

main().catch(err => {
  console.error(err);
  process.exit(1);
});

These TypeScript bindings would have to be part of a JSII library before they can be recognized and imported in Wing.

Component

SDK, CLI

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
@Chriscbr Chriscbr added ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl labels Nov 13, 2023
@monadabot monadabot added this to Wing Nov 13, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Nov 13, 2023
@Chriscbr Chriscbr changed the title Use uncommon Terraform providers in Wing How to use uncommon Terraform providers in Wing Nov 13, 2023
@Chriscbr Chriscbr added the 🐶 dogfood Discovered while dogfooding Winglang label Nov 13, 2023
@staycoolcall911 staycoolcall911 moved this from 🆕 New - not properly defined to 🤝 Backlog - handoff to owners in Wing Nov 14, 2023
Copy link

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@Chriscbr
Copy link
Contributor Author

This would let us create bindings for CIVO resources and use them in Wing: https://registry.terraform.io/providers/civo/civo/latest/docs

@Chriscbr Chriscbr added this to the Winglang Stable Release milestone Mar 5, 2024
@Chriscbr Chriscbr changed the title How to use uncommon Terraform providers in Wing Ability to generate Winglang bindings for arbitrary Terraform providers May 20, 2024
@Chriscbr Chriscbr changed the title Ability to generate Winglang bindings for arbitrary Terraform providers Generate Winglang bindings for arbitrary Terraform providers May 28, 2024
@eladb
Copy link
Contributor

eladb commented Jun 4, 2024

See tf.Resource for an untyped experience: https://github.com/winglang/winglibs/blob/main/tf/README.md

Should be pretty reasonable for most use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐶 dogfood Discovered while dogfooding Winglang ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl 🎨 sdk SDK
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

3 participants