steampipe icon indicating copy to clipboard operation
steampipe copied to clipboard

Mod fails if it requires a plugin that is installed but not configured

Open e-gineer opened this issue 2 years ago • 0 comments

Describe the bug

  • AWS plugin is installed
  • But no AWS connections are in the config
  • Mod will attempt to run (install requirement is met), but fails hard because there is no actual configured connection

Expected behavior

We should detect that no connections of the desired plugin version are available and refuse to run.

Additional context

/tmp $ steampipe --version
steampipe version 0.14.6
/tmp $ steampipe query
Welcome to Steampipe v0.14.6
For more information, type .help
> .inspect
+------------+-----------------------------------------------+
| connection | plugin                                        |
+------------+-----------------------------------------------+
| github     | hub.steampipe.io/plugins/turbot/github@latest |
| trivy      | hub.steampipe.io/plugins/turbot/trivy@latest  |
+------------+-----------------------------------------------+

To get information about the tables in a connection, run .inspect {connection}
To get information about the columns in a table, run .inspect {connection}.{table}

> 

/tmp $ 
/tmp $ steampipe plugin list
+----------------------------------------------------+---------+-------------+
| Name                                               | Version | Connections |
+----------------------------------------------------+---------+-------------+
| hub.steampipe.io/plugins/turbot/algolia@latest     | local   |             |
| hub.steampipe.io/plugins/turbot/aws@latest         | 0.60.0  |             |
| hub.steampipe.io/plugins/turbot/buildkite@latest   | local   |             |
| hub.steampipe.io/plugins/turbot/code@latest        | local   |             |
| hub.steampipe.io/plugins/turbot/config@latest      | local   |             |
| hub.steampipe.io/plugins/turbot/crtsh@latest       | local   |             |
| hub.steampipe.io/plugins/turbot/csv@latest         | 0.3.1   |             |
| hub.steampipe.io/plugins/turbot/duo@latest         | local   |             |
| hub.steampipe.io/plugins/turbot/git@latest         | local   |             |
| hub.steampipe.io/plugins/turbot/github@latest      | 0.15.0  | github      |
| hub.steampipe.io/plugins/turbot/hackernews@latest  | 0.3.1   |             |
| hub.steampipe.io/plugins/turbot/imap@latest        | local   |             |
| hub.steampipe.io/plugins/turbot/ipstack@latest     | 0.6.0   |             |
| hub.steampipe.io/plugins/turbot/linkedin@latest    | local   |             |
| hub.steampipe.io/plugins/turbot/net@latest         | 0.3.0   |             |
| hub.steampipe.io/plugins/turbot/panos@latest       | local   |             |
| hub.steampipe.io/plugins/turbot/planetscale@latest | local   |             |
| hub.steampipe.io/plugins/turbot/reddit@latest      | local   |             |
| hub.steampipe.io/plugins/turbot/rss@latest         | 0.2.1   |             |
| hub.steampipe.io/plugins/turbot/slack@latest       | 0.4.1   |             |
| hub.steampipe.io/plugins/turbot/terraform@latest   | 0.1.0   |             |
| hub.steampipe.io/plugins/turbot/trivy@latest       | local   | trivy       |
| hub.steampipe.io/plugins/turbot/twitter@latest     | 0.1.0   |             |
+----------------------------------------------------+---------+-------------+
/tmp $ 
/tmp $ cd ~/src/steampipe-mod-aws-compliance/
~/src/steampipe-mod-aws-compliance $ 
~/src/steampipe-mod-aws-compliance $ cat mod.sp 
// Benchmarks and controls for specific services should override the "service" tag
locals {
  aws_compliance_common_tags = {
    category = "Compliance"
    plugin   = "aws"
    service  = "AWS"
  }
}

mod "aws_compliance" {
  # hub metadata
  title         = "AWS Compliance"
  description   = "Run individual configuration, compliance and security controls or full compliance benchmarks for CIS, PCI, NIST, HIPAA, RBI CSF, GDPR, SOC 2, Audit Manager Control Tower and AWS Foundational Security Best Practices controls across all your AWS accounts using Steampipe."
  color         = "#FF9900"
  documentation = file("./docs/index.md")
  icon          = "/images/mods/turbot/aws-compliance.svg"
  categories    = ["aws", "cis", "compliance", "pci dss", "public cloud", "security"]

  opengraph {
    title       = "Steampipe Mod for AWS Compliance"
    description = "Run individual configuration, compliance and security controls or full compliance benchmarks for CIS, PCI, NIST, HIPAA, RBI CSF, GDPR, SOC 2, Audit Manager Control Tower and AWS Foundational Security Best Practices controls across all your AWS accounts using Steampipe."
    image       = "/images/mods/turbot/aws-compliance-social-graphic.png"
  }

  require {
    plugin "aws" {
      version = "0.59.0"
    }
  }
}
~/src/steampipe-mod-aws-compliance $ 
~/src/steampipe-mod-aws-compliance $ steampipe query
Welcome to Steampipe v0.14.6
For more information, type .help
> 
Warning: failed to create prepared statement for aws_compliance.control.elasticache_redis_cluster_automatic_backup_retention_15_days: ERROR: relation "aws_elasticache_replication_group" does not exist (SQLSTATE 42P01)
Warning: failed to create prepared statement for aws_compliance.control.cis_v130_1_18: ERROR: relation "aws_account" does not exist (SQLSTATE 42P01)
Warning: failed to create prepared statement for aws_compliance.control.cis_v140_5_2: ERROR: relation "aws_vpc_security_group_rule" does not exist (SQLSTATE 42P01)
Warning: failed to create prepared statement for aws_compliance.control.foundational_security_secretsmanager_4: ERROR: relation "aws_secretsmanager_secret" does not exist (SQLSTATE 42P01)
Warning: failed to create prepared statement for aws_compliance.control.cis_v130_4_7: ERROR: relation "aws_cloudtrail_trail" does not exist (SQLSTATE 42P01)
<snipped>
Warning: failed to create prepared statement for aws_compliance.control.autoscaling_group_with_lb_use_health_check: ERROR: relation "aws_ec2_autoscaling_group" does not exist (SQLSTATE 42P01)
> 

e-gineer avatar May 30 '22 10:05 e-gineer