steampipe-plugin-sdk
steampipe-plugin-sdk copied to clipboard
Getting an error when trying to load child properties of an object from the connection config
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.
- If at least one property of the assumeRoleConfig is not defined with
cty, then getting the below error -
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)
-
Without
ctylike Duration, ExternalId, and SessionName are not loading. -
If any property is defined with an optional and cty tag - like -> ExternalId *string
hcl:"external_id,optional" cty:"external_id"-
- When the ExternalId is present in the connection config, it works fine.
- If it is not present, then getting the below error and it is not honouring the optional tag-
Error: failed to start plugin 'hub.steampipe.io/plugins/turbot/aws@latest': failed to start 'hub.steampipe.io/plugins/turbot/aws@latest': failed to parse connection config for connection 'aws':
Unsuitable value type: Unsuitable value: attribute "external_id" is required
This could be due to the parsing mechanism - https://github.com/turbot/steampipe-plugin-sdk/blob/main/plugin/connection_config_schema.go#L88
Issue reference.
@bigdatasourav I cannot reproduce this
@kaidaguerre, as discussed, please test using the tet_assume_role branch in AWS plugin.