turbot / steampipe-plugin-sdk

Steampipe Plugin SDK is a simple abstraction layer to write a Steampipe plugin. Plugins automatically work across all engine types including the Steampipe CLI, Postgres FDW, SQLite extension and the export CLI.
https://hub.steampipe.io/plugins
Apache License 2.0
33 stars 16 forks source link

Getting an error when trying to load child properties of an object from the connection config #692

Open bigdatasourav opened 11 months ago

bigdatasourav commented 11 months ago

Here is a sample connection -

connection "aws" {
assume_role = {
   # role_arn = "arn:aws:iam::12345678:role/testAssume"
    #duration = "300s"
    #external_id = "123456"
    #session_name = "testSession"
  } 

regions = ["*"]
plugin    = "aws" 
}

Below is the schema -

type awsConfig struct {
    Regions               []string          `hcl:"regions,optional"`
    Profile               *string           `hcl:"profile,optional"`
    AssumeRole            *assumeRoleConfig `hcl:"assume_role,optional"`
}

type assumeRoleConfig struct {
    RoleARN     *string `hcl:"role_arn" cty:"role_arn"`
    Duration    *string `hcl:"duration,optional"`
    ExternalId  *string `hcl:"external_id,optional"`
    SessionName *string `hcl:"session_name,optional"`
}

Here, the awsConfig properties are loading correctly; they do not require to be defined with the cty. However, the properties of assumeRoleConfig, which is a child of awsConfig, are not loading as expected.

Error: failed to start plugin 'hub.steampipe.io/plugins/turbot/aws@latest': failed to start 'hub.steampipe.io/plugins/turbot/aws@latest': ConnectionConfigSchema parse failed with panic unsuitable DecodeExpression target: no cty.Type for aws.assumeRoleConfig (no cty field tags) 

This could be due to the parsing mechanism - https://github.com/turbot/steampipe-plugin-sdk/blob/main/plugin/connection_config_schema.go#L88

bigdatasourav commented 11 months ago

Issue reference.

kaidaguerre commented 11 months ago

@bigdatasourav I cannot reproduce this

bigdatasourav commented 11 months ago

@kaidaguerre, as discussed, please test using the tet_assume_role branch in AWS plugin.