github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/manual_testing/node_reuse/graph_as_node_invalid/dashboard.sp (about)

     1  dashboard "with_graph_as_node" {
     2    title = "With Graph as Node"
     3  
     4  
     5    input "instance_id" {
     6      title = "Select an instance:"
     7      query = query.ec2_instance_input
     8      width = 4
     9    }
    10  
    11     graph {
    12       base = graph.security_groups_to_vpc
    13       param "security_group_ids" {
    14         default = ["sg-0fb7e820f98871e0b", "sg-0963689e95ad3f4cb", "sg-0fa5ad244c986a9d8"]
    15       }
    16       param "subnet_ids" {
    17         default =   with.vpc.rows[*].vpc_id
    18       }
    19     }
    20  
    21    // vpc: vpc-0a93262e0a9f10dda
    22  
    23    graph "ec2_instance_detail" {
    24  
    25      with "security_groups" {
    26        sql = <<-EOQ
    27        select
    28          s ->> 'GroupId' as sg_id
    29        from
    30          aws_ec2_instance,
    31          jsonb_array_elements(security_groups) as s
    32        where
    33          instance_id = $1
    34      EOQ
    35  
    36        args = [self.input.instance_id.value]
    37      }
    38  
    39      with "vpc_details" {
    40        sql = <<-EOQ
    41        select
    42          instance_id,
    43          vpc_id,
    44          subnet_id
    45        from
    46          aws_ec2_instance
    47        where
    48          instance_id = $1
    49      EOQ
    50  
    51        args = [self.input.instance_id.value]
    52      }
    53  
    54  
    55      node {
    56        base = node.ec2_instance
    57        args = {
    58          ec2_instance_ids  = [self.input.instance_id]
    59        }
    60      }
    61  
    62      # graph {
    63      #   base = graph.security_groups_to_vpc
    64      #   args =  {
    65      #     security_group_ids        = with.security_groups.rows[*].sg_id
    66      #     subnet_ids    = with.vpc_details.rows[*].subnet_id
    67      #   }
    68      # }
    69  
    70      edge {
    71        base = edge.aws_ec2_instance_to_security_group
    72        args = {
    73          ec2_instance_id  = self.input.instance_id.value
    74        }
    75      }
    76  
    77    }
    78  
    79  }
    80  
    81  query "ec2_instance_input" {
    82    sql = <<-EOQ
    83      select
    84        title as label,
    85        instance_id as value,
    86        json_build_object(
    87          'account_id', account_id,
    88          'region', region,
    89          'instance_id', instance_id
    90        ) as tags
    91      from
    92        aws_ec2_instance
    93      order by
    94        title;
    95    EOQ
    96  }
    97  
    98  node "ec2_instance" {
    99    //category = category.ec2_instance
   100  
   101    sql = <<-EOQ
   102      select
   103        instance_id as id,
   104        title,
   105        jsonb_build_object(
   106          'Instance ID', instance_id,
   107          'Name', tags ->> 'Name',
   108          'ARN', arn,
   109          'Account ID', account_id,
   110          'Region', region
   111        ) as properties
   112      from
   113        aws_ec2_instance
   114      where
   115        instance_id = any($1);
   116    EOQ
   117  
   118    param "ec2_instance_ids" {}
   119  }
   120  
   121  edge "aws_ec2_instance_to_security_group" {
   122    title = "security group"
   123  
   124    sql = <<-EOQ
   125      select
   126        instance_id as from_id,
   127        sg ->> 'GroupId' as to_id
   128      from
   129        aws_ec2_instance,
   130        jsonb_array_elements(security_groups) as sg
   131      where
   132        instance_id = $1
   133    EOQ
   134  
   135    param "ec2_instance_id" {}
   136  }
   137  
   138  graph "security_groups_to_vpc" {
   139  
   140    param "security_group_ids" {}
   141    param "subnet_ids" {}
   142  
   143  
   144    with "vpc" {
   145      sql = <<-EOQ
   146        select
   147          vpc_id
   148        from
   149          aws_vpc_subnet
   150        where
   151          subnet_id = any ($1)
   152      EOQ
   153      args = [param.subnet_ids]
   154      //args = [["subnet-0b349fd9ce6590352", "subnet-05ec8288f0b9be5aa"]]
   155  
   156    }
   157  
   158  
   159    node {
   160      base = node.vpc_vpc
   161      args = {
   162        vpc_vpc_ids = with.vpc.rows[*].vpc_id
   163        //vpc_vpc_ids = ["vpc-0a93262e0a9f10dda"]
   164      }
   165    }
   166  
   167    node {
   168      base = node.vpc_subnet
   169      args = {
   170        vpc_subnet_ids = param.subnet_ids
   171        //vpc_subnet_ids = [["subnet-0b349fd9ce6590352", "subnet-05ec8288f0b9be5aa"]]
   172      }
   173    }
   174  
   175    node {
   176      base = node.vpc_security_group
   177      args = {
   178        vpc_security_group_ids = param.security_group_ids
   179        //vpc_security_group_ids = ["sg-0fb7e820f98871e0b", "sg-0963689e95ad3f4cb", "sg-0fa5ad244c986a9d8"]
   180      }
   181    }
   182  
   183    edge {
   184      base = edge.vpc_security_group_to_vpc_subnet
   185      args = {
   186        vpc_security_group_ids = param.security_group_ids
   187      }
   188    }
   189  
   190    edge {
   191      base = edge.vpc_subnet_to_vpc
   192      args = {
   193        vpc_subnet_ids = param.subnet_ids
   194      }
   195    }
   196  
   197  }
   198  
   199  node "vpc_vpc" {
   200    //category = category.vpc_vpc
   201  
   202    sql = <<-EOQ
   203     select
   204        vpc_id as id,
   205        title as title,
   206        jsonb_build_object(
   207          'ARN', arn,
   208          'VPC ID', vpc_id,
   209          'Is Default', is_default,
   210          'State', state,
   211          'CIDR Block', cidr_block,
   212          'DHCP Options ID', dhcp_options_id,
   213          'Owner ID', owner_id,
   214          'Account ID', account_id,
   215          'Region', region
   216        ) as properties
   217      from
   218        aws_vpc
   219      where
   220        vpc_id = any($1 ::text[]);
   221    EOQ
   222  
   223    param "vpc_vpc_ids" {}
   224  }
   225  
   226  node "vpc_security_group" {
   227    //category = category.vpc_security_group
   228  
   229    sql = <<-EOQ
   230      select
   231        group_id as id,
   232        title as title,
   233        jsonb_build_object(
   234          'Group ID', group_id,
   235          'Description', description,
   236          'ARN', arn,
   237          'Account ID', account_id,
   238          'Region', region
   239        ) as properties
   240      from
   241        aws_vpc_security_group
   242      where
   243        group_id = any($1 ::text[]);
   244    EOQ
   245  
   246    param "vpc_security_group_ids" {}
   247  }
   248  
   249  node "vpc_subnet" {
   250    //category = category.vpc_subnet
   251  
   252    sql = <<-EOQ
   253     select
   254        subnet_id as id,
   255        title as title,
   256        jsonb_build_object(
   257          'Subnet ID', subnet_id,
   258          'ARN', subnet_arn,
   259          'VPC ID', vpc_id,
   260          'Account ID', account_id,
   261          'Region', region
   262        ) as properties
   263      from
   264        aws_vpc_subnet
   265      where
   266        subnet_id = any($1 ::text[]);
   267    EOQ
   268  
   269    param "vpc_subnet_ids" {}
   270  }
   271  
   272  edge "vpc_subnet_to_vpc" {
   273    title = "vpc"
   274  
   275    sql = <<-EOQ
   276      select
   277        subnet_id as from_id,
   278        vpc_id as to_id
   279      from
   280        aws_vpc_subnet
   281      where
   282        subnet_id = any($1)
   283    EOQ
   284  
   285    param "vpc_subnet_ids" {}
   286  }
   287  
   288  edge "vpc_security_group_to_vpc_subnet" {
   289    title = "subnet"
   290  
   291    sql = <<-EOQ
   292      select
   293        subnet.subnet_id as from_id,
   294        sg.group_id as to_id
   295      from
   296        aws_vpc_security_group as sg,
   297        aws_svpc_subnet as subnet
   298      where
   299        sg.vpc_id = subnet.vpc_id
   300        and sg.group_id = any($1)
   301    EOQ
   302  
   303    param "vpc_security_group_ids" {}
   304  }