pulumi / pulumi-terraform-bridge

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

cannot encode resource inputs to call ValidateResourceConfig #2219

Open dirien opened 1 month ago

dirien commented 1 month ago

What happened?

I'm trying to import an existing Port Blueprint into my Pulumi project using the pulumi import command. However, I'm encountering errors during the import process. Specifically, when running the following command:

pulumi import port:index/blueprint:Blueprint teamBlueprint _team

I'm getting the following error:

error: Preview failed: cannot encode resource inputs to call ValidateResourceConfig: objectEncoder failed on property "properties": objectEncoder failed on property "string_props": encMap failed on {[]}

My Terraform configuration for this Blueprint is:

terraform {
  required_providers {
    port = {
      source  = "port-labs/port-labs"
      version = "~> 2.0.0"
    }
  }

}

resource "port_blueprint" "teamBlueprint" {
  title       = "Team"
  identifier  = "_team"
  description = "This blueprint is synced with Port teams"
  icon        = "Team"
  properties = {
    string_props = {
      "description" = {
        title = "Description"
      }
    }
  }
}

Example

-

Output of pulumi about

CLI          
Version      3.124.0
Go Version   go1.22.5
Go Compiler  gc

Plugins
KIND      NAME    VERSION
language  nodejs  unknown
resource  port    2.0.12

Host     
OS       darwin
Version  14.2.1
Arch     arm64

This project is written in nodejs: executable='/Users/dirien/.nvm/versions/node/v18.20.2/bin/node' version='v18.20.2'

Current Stack: dirien/import-test/dev

Found no resources associated with dev

Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/dirien
User           dirien
Organizations  dirien, ediri, pulumi
Token type     personal

Dependencies:
NAME             VERSION
@port-labs/port  2.0.12
@pulumi/pulumi   3.125.0
@types/node      18.19.41
typescript       5.5.3

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

guineveresaenger commented 1 month ago

Thank you for filing this issue. We'll take a look at fixing this as soon as we can.

VenelinMartinov commented 1 week ago

Had a brief look here, linking some references from the upstream provider:

The resource is using PF and the schema for the property giving the error is here: https://github.com/port-labs/terraform-provider-port-labs/blob/main/port/blueprint/schema.go#L43

It's a SingleNestedProperty, so we might be doing something wrong with the MaxItemsOne flattening, if that applies here.

VenelinMartinov commented 1 week ago

I've tried to repro this in https://github.com/pulumi/pulumi-terraform-bridge/pull/2396 but have been unable to so far.

@dirien can you please include the GRPC logs of the issue? You can get these with PULUMI_DEBUG_GRPC="grpc.json" prefixed to your import command, like so:

PULUMI_DEBUG_GRPC="grpc.json" pulumi import port:index/blueprint:Blueprint teamBlueprint _team

These should contain the information on what is returned from the provider when importing, as it seems like that does not pass Check