Skip to content

[REQ] Terraform Provider client generatorΒ #15889

Closed

Description

@jasondamour

Feature Request

Terraform Providers seem to be 95% boilerplate code, and could be generated via the OpenAPI spec along with vendor extensions and support for user-written code

Describe the solution you'd like

I would like to generate the resource and data resource schemas, and the read/create/update/delete methods based on the data in an openapi spec.

A generated provider may depend on a pre-generated go client. I'm not sure if theres any other examples in openapi-generator of a generated client depending on another generated client, or if the terraform client should just generate its own prepackaged go client.

Describe alternatives you've considered

The google and google-beta providers are already mostly auto-generated via a custom tool called Magic Modules. The tool supports generated code (with plenty of terraform-specific decorators) as well as handwritten code. However, it would be better to use OpenAPI as its a ubiquitous standard.

Additional context

Activity

  1. wing328 commented on Jun 21, 2023

    @wing328
    Member

    @jasondamour thanks for the suggestion. Would you be able to contribute a PR to add the Terraform Provider client generator or sponsor the community to work on it?

  2. jasondamour commented on Jun 21, 2023

    @jasondamour
    ContributorAuthor

    I'll take a first stab

  3. wing328 commented on Jun 21, 2023

    @wing328
    Member

    πŸ‘

    let me know if you need any help

  4. wing328 commented on Jun 21, 2023

    @wing328
    Member

    I think a good starting point is to find an existing generator that's similar to Terraform Provider client and clone it to start with.

  5. jasondamour commented on Jun 21, 2023

    @jasondamour
    ContributorAuthor

    @wing328 Do you know any reference or other instance where one generated client depends on another? In this case, terraform client might depend on golang client. Or does the terraform client need to be entirely self-contained, and generate its own golang client?

    Another instance I think this could apply is if OpenAPI supported generating a CLI in another language other than bash, for example with Python. It would require first generating a Python client SDK, then that could be used to generate a Python CLI.

    Is there any guidance on how to support these 2nd level generated clients?

  6. wing328 commented on Jun 22, 2023

    @wing328
    Member

    Previously the PowerShell client generator depended on the C# SDK (auto-generated API client).

    In this case, terraform client might depend on golang client.

    I would suggest generating the terraform client and go client via 2 separate generators to start with. In other words, you only need to create Terraform client generator (TerraformClientCodegen.java) for day 1 requirement and we will start from there.

  7. wing328 commented on Sep 5, 2023

    @wing328
    Member

    @roopakv thanks for informing us there's another generator available out there. As we told the author of another generator in our Slack channel a few weeks ago, we're not against any other specifications/generators but this is not the right place to market other specifications/generators so we've deleted your message.

  8. deleted a comment from roopakv on Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions