Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bigdatasourav opened this issue Oct 25, 2023 · 3 comments
Assignees

Comments

@bigdatasourav
Copy link

bigdatasourav commented Oct 25, 2023

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 cty like 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" -

  1. When the ExternalId is present in the connection config, it works fine.
  2. 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

@bigdatasourav
Copy link
Author

Issue reference.

@kaidaguerre
Copy link
Contributor

@bigdatasourav I cannot reproduce this

@bigdatasourav
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants