pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
194 stars 43 forks source link

Specific field isnt triggering update endpoint or showing diffs. #2454

Open KnockOutEZ opened 1 day ago

KnockOutEZ commented 1 day ago

Hey everyone,

I've encountered an issue with a Pulumi provider I built using pulumi-terraform-bridge. The provider isn't showing diffs for changes in a specific field when I try to update using pulumi up. This is happening despite the underlying Terraform provider working correctly.

The field in question is a list of nested attributes called "nodes" in my database resource. Here's a simplified version of the schema:

"nodes": schema.ListNestedAttribute{
    Computed: true,
    Optional: true,
    NestedObject: schema.NestedAttributeObject{
        Attributes: map[string]schema.Attribute{
            "name": schema.StringAttribute{
                Computed: true,
                Optional: true,
            },
            // ... other nested attributes ...
        },
    },
},

Normally, adding or removing an item like {name: "new_node"} in this array should trigger an update. However, the Pulumi provider doesn't seem to detect any changes to the "nodes" field at all.

I've confirmed that the nodes are being saved correctly, but Pulumi isn't recognizing the changes. I'm using terraform-plugin-framework to build my Terraform provider.

A couple of questions:

  1. Could this be related to the use of custom plan modifiers like conditionalUseStateForUnknownModifier?
  2. Does pulumi-terraform-bridge support custom plan modifiers from terraform-plugin-framework?

Has anyone encountered similar issues or have suggestions on how to troubleshoot this? Any insights would be greatly appreciated!

KnockOutEZ commented 1 day ago

This is the full portion for the nodes resource schema:

 "nodes": schema.ListNestedAttribute{
                 Description: "List of nodes in the database.",
                 Computed:    true,
                 Optional:    true,
                 NestedObject: schema.NestedAttributeObject{
                     Attributes: map[string]schema.Attribute{
                         "name": schema.StringAttribute{
                             Computed: true,
                             Optional: true,
                         },
                         "connection": schema.SingleNestedAttribute{
                             Computed: true,
                             PlanModifiers: []planmodifier.Object{
                                 objectplanmodifier.UseStateForUnknown(),
                             },
                             Attributes: map[string]schema.Attribute{
                                 "database":            schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "host":                schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "password":            schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "port":                schema.Int64Attribute{Computed: true, PlanModifiers: []planmodifier.Int64{int64planmodifier.UseStateForUnknown()}},
                                 "username":            schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "external_ip_address": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "internal_ip_address": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "internal_host":       schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                             },
                         },
                         "location": schema.SingleNestedAttribute{
                             Computed: true,
                             PlanModifiers: []planmodifier.Object{
                                 objectplanmodifier.UseStateForUnknown(),
                             },
                             Attributes: map[string]schema.Attribute{
                                 "code":        schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "country":     schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "latitude":    schema.Float64Attribute{Computed: true, PlanModifiers: []planmodifier.Float64{float64planmodifier.UseStateForUnknown()}},
                                 "longitude":   schema.Float64Attribute{Computed: true, PlanModifiers: []planmodifier.Float64{float64planmodifier.UseStateForUnknown()}},
                                 "name":        schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "region":      schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "region_code": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "timezone":    schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "postal_code": schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "metro_code":  schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "city":        schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                             },
                         },
                         "region": schema.SingleNestedAttribute{
                             Computed: true,
                             PlanModifiers: []planmodifier.Object{
                                 objectplanmodifier.UseStateForUnknown(),
                             },
                             Attributes: map[string]schema.Attribute{
                                 "active":             schema.BoolAttribute{Computed: true, PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()}},
                                 "availability_zones": schema.ListAttribute{Computed: true, ElementType: types.StringType, PlanModifiers: []planmodifier.List{listplanmodifier.UseStateForUnknown()}},
                                 "cloud":              schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "code":               schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "name":               schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                                 "parent":             schema.StringAttribute{Computed: true, PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()}},
                             },
                         },
                         "extensions": schema.SingleNestedAttribute{
                             Computed: true,
                             PlanModifiers: []planmodifier.Object{
                                 conditionalUseStateForUnknownModifier{},
                             },
                             Attributes: map[string]schema.Attribute{
                                 "errors":    schema.MapAttribute{Computed: true, ElementType: types.StringType, PlanModifiers: []planmodifier.Map{mapplanmodifier.UseStateForUnknown()}},
                                 "installed": schema.ListAttribute{Computed: true, ElementType: types.StringType, PlanModifiers: []planmodifier.List{listplanmodifier.UseStateForUnknown()}},
                             },
                         },
                     },
                 },
             },

The Terraform provider is in github.com/pgEdge/terraform-provider-pgedge And the pulumi provider is in github.com/pgEdge/pulumi-pgedge. (sync-v007 branch)