github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/tests/manual_testing/node_reuse/node_base_param_deps/dashboard.sp (about) 1 dashboard "name_graph" { 2 3 title = "named graph with base and args" 4 5 input "bucket_arn" { 6 title = "Select a bucket:" 7 query = query.s3_bucket_input 8 width = 4 9 } 10 11 with "bucket_policy" { 12 sql = <<-EOQ 13 select 14 policy_std 15 from 16 aws_s3_bucket 17 where 18 arn = $1; 19 EOQ 20 21 args = [self.input.bucket_arn.value] 22 } 23 24 graph { 25 base = graph.iam_policy_structure 26 args = { 27 policy_std = with.bucket_policy.rows[0].policy_std 28 } 29 } 30 } 31 32 33 query "s3_bucket_input" { 34 sql = <<-EOQ 35 select 36 title as label, 37 arn as value, 38 json_build_object( 39 'account_id', account_id, 40 'region', region 41 ) as tags 42 from 43 aws_s3_bucket 44 order by 45 title; 46 EOQ 47 } 48 49 50 51 //** The Graph.... 52 53 graph "iam_policy_structure" { 54 title = "IAM Policy" 55 56 param "policy_std" {} 57 58 # node { 59 # base = node.iam_policy_statement 60 # args = { 61 # iam_policy_std = param.policy_std 62 # } 63 # } 64 65 node { 66 base = node.iam_policy_statement_action_notaction 67 args = { 68 iam_policy_std = param.policy_std 69 } 70 } 71 72 node { 73 base = node.iam_policy_statement_condition 74 args = { 75 iam_policy_std = param.policy_std 76 } 77 } 78 79 node { 80 base = node.iam_policy_statement_condition_key 81 args = { 82 iam_policy_std = param.policy_std 83 } 84 } 85 86 node { 87 base = node.iam_policy_statement_condition_key_value 88 args = { 89 iam_policy_std = param.policy_std 90 } 91 } 92 93 node { 94 base = node.iam_policy_statement_resource_notresource 95 args = { 96 iam_policy_std = param.policy_std 97 } 98 } 99 100 101 # edge { 102 # base = edge.iam_policy_statement 103 # args = { 104 # iam_policy_arns = [self.input.policy_arn.value] 105 # } 106 # } 107 108 edge { 109 base = edge.iam_policy_statement_action 110 args = { 111 iam_policy_std = param.policy_std 112 } 113 } 114 115 edge { 116 base = edge.iam_policy_statement_condition 117 args = { 118 iam_policy_std = param.policy_std 119 } 120 } 121 122 edge { 123 base = edge.iam_policy_statement_condition_key 124 args = { 125 iam_policy_std = param.policy_std 126 } 127 } 128 129 edge { 130 base = edge.iam_policy_statement_condition_key_value 131 args = { 132 iam_policy_std = param.policy_std 133 } 134 } 135 136 edge { 137 base = edge.iam_policy_statement_notaction 138 args = { 139 iam_policy_std = param.policy_std 140 } 141 } 142 143 edge { 144 base = edge.iam_policy_statement_notresource 145 args = { 146 iam_policy_std = param.policy_std 147 } 148 } 149 150 edge { 151 base = edge.iam_policy_statement_resource 152 args = { 153 iam_policy_std = param.policy_std 154 } 155 } 156 } 157 158 159 160 // nodes 161 162 163 node "iam_policy_statement" { 164 category = category.iam_policy_statement 165 166 sql = <<-EOQ 167 select 168 concat('statement:', i) as id, 169 coalesce ( 170 t.stmt ->> 'Sid', 171 concat('[', i::text, ']') 172 ) as title 173 from 174 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i) 175 EOQ 176 177 param "iam_policy_std" {} 178 } 179 180 node "iam_policy_statement_action_notaction" { 181 category = category.iam_policy_action 182 183 sql = <<-EOQ 184 185 select 186 concat('action:', action) as id, 187 action as title 188 from 189 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 190 jsonb_array_elements_text(coalesce(t.stmt -> 'Action','[]'::jsonb) || coalesce(t.stmt -> 'NotAction','[]'::jsonb)) as action 191 EOQ 192 193 param "iam_policy_std" {} 194 } 195 196 node "iam_policy_statement_condition" { 197 category = category.iam_policy_condition 198 199 sql = <<-EOQ 200 select 201 condition.key as title, 202 concat('statement:', i, ':condition:', condition.key ) as id, 203 condition.value as properties 204 from 205 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 206 jsonb_each(t.stmt -> 'Condition') as condition 207 where 208 stmt -> 'Condition' <> 'null' 209 EOQ 210 211 param "iam_policy_std" {} 212 } 213 214 node "iam_policy_statement_condition_key" { 215 category = category.iam_policy_condition_key 216 217 sql = <<-EOQ 218 select 219 condition_key.key as title, 220 concat('statement:', i, ':condition:', condition.key, ':', condition_key.key ) as id, 221 condition_key.value as properties 222 from 223 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 224 jsonb_each(t.stmt -> 'Condition') as condition, 225 jsonb_each(condition.value) as condition_key 226 where 227 stmt -> 'Condition' <> 'null' 228 EOQ 229 230 param "iam_policy_std" {} 231 } 232 233 node "iam_policy_statement_condition_key_value" { 234 category = category.iam_policy_condition_value 235 236 sql = <<-EOQ 237 select 238 condition_value as title, 239 concat('statement:', i, ':condition:', condition.key, ':', condition_key.key, ':', condition_value ) as id 240 from 241 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 242 jsonb_each(t.stmt -> 'Condition') as condition, 243 jsonb_each(condition.value) as condition_key, 244 jsonb_array_elements_text(condition_key.value) as condition_value 245 where 246 stmt -> 'Condition' <> 'null' 247 EOQ 248 249 param "iam_policy_std" {} 250 } 251 252 node "iam_policy_statement_resource_notresource" { 253 category = category.iam_policy_resource 254 255 sql = <<-EOQ 256 select 257 resource as id, 258 resource as title 259 from 260 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 261 jsonb_array_elements_text(coalesce(t.stmt -> 'Action','[]'::jsonb) || coalesce(t.stmt -> 'NotAction','[]'::jsonb)) as action, 262 jsonb_array_elements_text(coalesce(t.stmt -> 'Resource','[]'::jsonb) || coalesce(t.stmt -> 'NotResource','[]'::jsonb)) as resource 263 EOQ 264 265 param "iam_policy_std" {} 266 } 267 268 269 // edges 270 271 edge "iam_policy_statement_action" { 272 //title = "allows" 273 sql = <<-EOQ 274 275 select 276 --distinct on (p.arn,action) 277 concat('action:', action) as to_id, 278 concat('statement:', i) as from_id, 279 lower(t.stmt ->> 'Effect') as title, 280 lower(t.stmt ->> 'Effect') as category 281 from 282 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 283 jsonb_array_elements_text(t.stmt -> 'Action') as action 284 EOQ 285 286 param "iam_policy_std" {} 287 } 288 289 edge "iam_policy_statement_condition" { 290 title = "condition" 291 sql = <<-EOQ 292 293 select 294 concat('statement:', i, ':condition:', condition.key) as to_id, 295 concat('statement:', i) as from_id 296 from 297 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 298 jsonb_each(t.stmt -> 'Condition') as condition 299 where 300 stmt -> 'Condition' <> 'null' 301 EOQ 302 303 param "iam_policy_std" {} 304 } 305 306 edge "iam_policy_statement_condition_key" { 307 title = "all of" 308 sql = <<-EOQ 309 select 310 concat('statement:', i, ':condition:', condition.key, ':', condition_key.key ) as to_id, 311 concat('statement:', i, ':condition:', condition.key) as from_id 312 from 313 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 314 jsonb_each(t.stmt -> 'Condition') as condition, 315 jsonb_each(condition.value) as condition_key 316 where 317 stmt -> 'Condition' <> 'null' 318 EOQ 319 320 param "iam_policy_std" {} 321 } 322 323 edge "iam_policy_statement_condition_key_value" { 324 title = "any of" 325 sql = <<-EOQ 326 select 327 concat('statement:', i, ':condition:', condition.key, ':', condition_key.key, ':', condition_value ) as to_id, 328 concat('statement:', i, ':condition:', condition.key, ':', condition_key.key ) as from_id 329 from 330 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 331 jsonb_each(t.stmt -> 'Condition') as condition, 332 jsonb_each(condition.value) as condition_key, 333 jsonb_array_elements_text(condition_key.value) as condition_value 334 where 335 stmt -> 'Condition' <> 'null' 336 EOQ 337 338 param "iam_policy_std" {} 339 } 340 341 edge "iam_policy_statement_notaction" { 342 sql = <<-EOQ 343 344 select 345 --distinct on (p.arn,notaction) 346 concat('action:', notaction) as to_id, 347 concat('statement:', i) as from_id, 348 concat(lower(t.stmt ->> 'Effect'), ' not action') as title, 349 lower(t.stmt ->> 'Effect') as category 350 from 351 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i), 352 jsonb_array_elements_text(t.stmt -> 'NotAction') as notaction 353 EOQ 354 355 param "iam_policy_std" {} 356 } 357 358 edge "iam_policy_statement_notresource" { 359 title = "not resource" 360 361 sql = <<-EOQ 362 select 363 concat('action:', coalesce(action, notaction)) as from_id, 364 notresource as to_id, 365 lower(stmt ->> 'Effect') as category 366 from 367 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i) 368 left join jsonb_array_elements_text(stmt -> 'Action') as action on true 369 left join jsonb_array_elements_text(stmt -> 'NotAction') as notaction on true 370 left join jsonb_array_elements_text(stmt -> 'NotResource') as notresource on true 371 EOQ 372 373 param "iam_policy_std" {} 374 } 375 376 edge "iam_policy_statement_resource" { 377 title = "resource" 378 379 sql = <<-EOQ 380 select 381 concat('action:', coalesce(action, notaction)) as from_id, 382 resource as to_id, 383 lower(stmt ->> 'Effect') as category 384 from 385 jsonb_array_elements(($1 :: jsonb) -> 'Statement') with ordinality as t(stmt,i) 386 left join jsonb_array_elements_text(stmt -> 'Action') as action on true 387 left join jsonb_array_elements_text(stmt -> 'NotAction') as notaction on true 388 left join jsonb_array_elements_text(stmt -> 'Resource') as resource on true 389 EOQ 390 391 param "iam_policy_std" {} 392 } 393 394 395 396 // categories 397 398 399 category "iam_policy" { 400 title = "IAM Policy" 401 color = local.iam_color 402 href = "/aws_insights.dashboard.iam_policy_detail?input.policy_arn={{.properties.'ARN' | @uri}}" 403 icon = "rule" 404 } 405 406 category "iam_policy_action" { 407 href = "/aws_insights.dashboard.iam_action_glob_report?input.action_glob={{.title | @uri}}" 408 icon = "electric-bolt" 409 color = local.iam_color 410 title = "Action" 411 } 412 413 category "iam_policy_condition" { 414 icon = "help" 415 color = local.iam_color 416 title = "Condition" 417 } 418 419 category "iam_policy_condition_key" { 420 icon = "vpn-key" 421 color = local.iam_color 422 title = "Condition Key" 423 } 424 425 category "iam_policy_condition_value" { 426 icon = "text:val" 427 color = local.iam_color 428 title = "Condition Value" 429 } 430 431 category "iam_policy_notaction" { 432 icon = "flash-off" 433 color = local.iam_color 434 title = "NotAction" 435 } 436 437 category "iam_policy_notresource" { 438 icon = "bookmark-remove" 439 color = local.iam_color 440 title = "NotResource" 441 } 442 443 category "iam_policy_resource" { 444 icon = "bookmark" 445 color = local.iam_color 446 title = "Resource" 447 } 448 449 category "iam_policy_statement" { 450 icon = "assignment" 451 color = local.iam_color 452 title = "Statement" 453 } 454 455 456 457 // color 458 459 locals { 460 analytics_color = "purple" 461 application_integration_color = "deeppink" 462 ar_vr_color = "deeppink" 463 blockchain_color = "orange" 464 business_application_color = "red" 465 compliance_color = "orange" 466 compute_color = "orange" 467 containers_color = "orange" 468 content_delivery_color = "purple" 469 cost_management_color = "green" 470 database_color = "blue" 471 developer_tools_color = "blue" 472 end_user_computing_color = "green" 473 front_end_web_color = "red" 474 game_tech_color = "purple" 475 iam_color = "red" 476 iot_color = "green" 477 management_governance_color = "pink" 478 media_color = "orange" 479 migration_transfer_color = "green" 480 ml_color = "green" 481 mobile_color = "red" 482 networking_color = "purple" 483 quantum_technologies_color = "orange" 484 robotics_color = "red" 485 satellite_color = "blue" 486 security_color = "red" 487 storage_color = "green" 488 }