hashicorp / terraform-plugin-codegen-framework

Terraform Provider Code Generation Specification to Framework
Mozilla Public License 2.0
39 stars 17 forks source link

Support `timeouts` attribute from the codegen framework #143

Open TheNilesh opened 5 months ago

TheNilesh commented 5 months ago

Use Cases or Problem Statement

Terraform lets you set timeouts in your resource configuration. However, the Terraform Plugin Codegen Framework doesn't have a way to add timeouts in the provider_code_spec.json file. This means the framework can't generate code that looks like this:

func (t *exampleResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
    resp.Schema = schema.Schema{
        Attributes: map[string]schema.Attribute{
            /* ... */
            "timeouts": timeouts.Attributes(ctx, timeouts.Opts{
                Create: true,
            }),
        },

I don't think the framework has built-in support for timeouts. I'm curious if there is an alternative approach or workaround that would allow me to include timeouts. Is it possible to use dynamic types, object types, or any other method to read timeouts value from the resource definition?

Proposal

Modify JSON schema to include special timeouts type.

Additional Information

No response

Code of Conduct