cid-cmd 0.3.2__tar.gz → 0.3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. {cid_cmd-0.3.2/cid_cmd.egg-info → cid_cmd-0.3.8}/PKG-INFO +1 -1
  2. cid_cmd-0.3.8/cid/_version.py +1 -0
  3. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/summary_view.sql +4 -1
  4. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/summary_view_ri.sql +4 -2
  5. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/summary_view_sp.sql +4 -2
  6. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/summary_view_sp_ri.sql +4 -2
  7. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/hourly_view.sql +5 -2
  8. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/hourly_view_ri.sql +5 -2
  9. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/hourly_view_sp.sql +5 -2
  10. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/hourly_view_sp_ri.sql +5 -2
  11. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/resource_view.sql +5 -2
  12. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/resource_view_ri.sql +5 -2
  13. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/resource_view_sp.sql +5 -2
  14. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cudos/resource_view_sp_ri.sql +5 -2
  15. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/cli.py +8 -4
  16. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/common.py +28 -14
  17. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/athena.py +18 -19
  18. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/cur.py +7 -4
  19. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/iam.py +25 -8
  20. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/quicksight/__init__.py +2 -2
  21. {cid_cmd-0.3.2 → cid_cmd-0.3.8/cid_cmd.egg-info}/PKG-INFO +1 -1
  22. cid_cmd-0.3.2/cid/_version.py +0 -1
  23. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/LICENSE +0 -0
  24. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/MANIFEST.in +0 -0
  25. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/README.md +0 -0
  26. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/__init__.py +0 -0
  27. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/base.py +0 -0
  28. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/__init__.py +0 -0
  29. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/__init__.py +0 -0
  30. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/cid/compute.json +0 -0
  31. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/cid/ec2_running_cost.json +0 -0
  32. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/cid/s3_view.json +0 -0
  33. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/cid/summary_view.json +0 -0
  34. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/co/dataset.json +0 -0
  35. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/cudos/hourly_view.json +0 -0
  36. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/cudos/resource_view.json +0 -0
  37. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/kpi/kpi_ebs_snap.json +0 -0
  38. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/kpi/kpi_ebs_storage_all.json +0 -0
  39. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/kpi/kpi_instance_all.json +0 -0
  40. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/kpi/kpi_s3_storage_all.json +0 -0
  41. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/kpi/kpi_tracker.json +0 -0
  42. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/shared/customer_all.json +0 -0
  43. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/tao/dataset.json +0 -0
  44. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/trends/daily_anomaly_detection.json +0 -0
  45. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/trends/monthly_anomaly_detection.json +0 -0
  46. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/datasets/trends/monthly_bill_by_account.json +0 -0
  47. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/permissions/dashboard_permissions.json +0 -0
  48. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/permissions/dashboard_permissions_namespace.json +0 -0
  49. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/permissions/data_set_permissions.json +0 -0
  50. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/permissions/data_source_permissions.json +0 -0
  51. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/permissions/folder_permissions.json +0 -0
  52. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/compute_savings_plan_eligible_spend.sql +0 -0
  53. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ec2_running_cost.sql +0 -0
  54. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ec2_running_cost_ri.sql +0 -0
  55. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ec2_running_cost_sp.sql +0 -0
  56. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ec2_running_cost_sp_ri.sql +0 -0
  57. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ri_sp_mapping.sql +0 -0
  58. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ri_sp_mapping_ri.sql +0 -0
  59. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ri_sp_mapping_sp.sql +0 -0
  60. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/ri_sp_mapping_sp_ri.sql +0 -0
  61. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/cid/s3.sql +0 -0
  62. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/all_options.sql +0 -0
  63. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/auto_scale.json +0 -0
  64. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/auto_scale_options.sql +0 -0
  65. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/ebs_volume.json +0 -0
  66. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/ebs_volume_options.sql +0 -0
  67. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/ec2_instance.json +0 -0
  68. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/ec2_instance_options.sql +0 -0
  69. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/lambda.json +0 -0
  70. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/co/lambda_options.sql +0 -0
  71. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/first_kpi_instance_mapping_view.sql +0 -0
  72. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/kpi_ebs_snap_view.sql +0 -0
  73. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/kpi_ebs_storage_view.sql +0 -0
  74. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/kpi_instance_all_view.sql +0 -0
  75. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/kpi_instance_all_view_noRI.sql +0 -0
  76. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/kpi_instance_all_view_noRISP.sql +0 -0
  77. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/kpi_instance_all_view_noSP.sql +0 -0
  78. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/kpi_s3_storage_view.sql +0 -0
  79. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/kpi/last_kpi_tracker_view.sql +0 -0
  80. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/account_map.sql +0 -0
  81. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/account_map_dummy.sql +0 -0
  82. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/aws_accounts.sql +0 -0
  83. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/aws_regions.sql +0 -0
  84. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/aws_service_category_map.sql +0 -0
  85. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/business_units_map.sql +0 -0
  86. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/cur.yaml +0 -0
  87. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/payer_account_name_map.sql +0 -0
  88. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/shared/ta_descriptions.sql +0 -0
  89. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/tao/glue_table.json +0 -0
  90. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/tao/ta_org_view.sql +0 -0
  91. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/trends/daily_anomaly_detection.sql +0 -0
  92. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/trends/monthly_anomaly_detection.sql +0 -0
  93. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/trends/monthly_bill_by_account.sql +0 -0
  94. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/trends/monthly_bill_by_account_ri.sql +0 -0
  95. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/trends/monthly_bill_by_account_sp.sql +0 -0
  96. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/queries/trends/monthly_bill_by_account_sp_ri.sql +0 -0
  97. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/builtin/core/data/resources.yaml +0 -0
  98. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/commands/__init__.py +0 -0
  99. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/commands/command_base.py +0 -0
  100. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/commands/init_qs.py +0 -0
  101. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/exceptions.py +0 -0
  102. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/export.py +0 -0
  103. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/__init__.py +0 -0
  104. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/account_map.py +0 -0
  105. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/csv2view.py +0 -0
  106. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/diff.py +0 -0
  107. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/glue.py +0 -0
  108. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/organizations.py +0 -0
  109. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/quicksight/dashboard.py +0 -0
  110. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/quicksight/dataset.py +0 -0
  111. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/quicksight/datasource.py +0 -0
  112. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/quicksight/resource.py +0 -0
  113. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/quicksight/template.py +0 -0
  114. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/randtime.py +0 -0
  115. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/s3.py +0 -0
  116. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/helpers/timezone.py +0 -0
  117. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/logger.py +0 -0
  118. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/plugin.py +0 -0
  119. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/test/python/test_csv2view.py +0 -0
  120. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/test/python/test_isolated_parameters.py +0 -0
  121. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/test/python/test_merge.py +0 -0
  122. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid/utils.py +0 -0
  123. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid_cmd.egg-info/SOURCES.txt +0 -0
  124. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid_cmd.egg-info/dependency_links.txt +0 -0
  125. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid_cmd.egg-info/entry_points.txt +0 -0
  126. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid_cmd.egg-info/requires.txt +0 -0
  127. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/cid_cmd.egg-info/top_level.txt +0 -0
  128. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/pyproject.toml +0 -0
  129. {cid_cmd-0.3.2 → cid_cmd-0.3.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cid-cmd
3
- Version: 0.3.2
3
+ Version: 0.3.8
4
4
  Summary: Cloud Intelligence Dashboards deployment helper tool
5
5
  Home-page: https://github.com/aws-samples/aws-cudos-framework-deployment
6
6
  Author: AWS CUDOS Team
@@ -0,0 +1 @@
1
+ __version__ = '0.3.8'
@@ -83,5 +83,8 @@
83
83
  WHEN ("line_item_line_item_type" <> 'SavingsPlanNegation') THEN "pricing_public_on_demand_cost" ELSE 0 END) "public_cost"
84
84
  FROM
85
85
  "${cur_table_name}"
86
- WHERE (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)))
86
+ WHERE
87
+ (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH))
88
+ AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH))
89
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
87
90
  GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,33,34
@@ -73,6 +73,8 @@
73
73
  WHEN ("line_item_line_item_type" <> 'SavingsPlanNegation') THEN "pricing_public_on_demand_cost" ELSE 0 END) "public_cost"
74
74
  FROM
75
75
  "${cur_table_name}"
76
- WHERE (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)))
77
-
76
+ WHERE
77
+ (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH))
78
+ AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH))
79
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
78
80
  GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,33,34
@@ -77,6 +77,8 @@
77
77
  WHEN ("line_item_line_item_type" <> 'SavingsPlanNegation') THEN "pricing_public_on_demand_cost" ELSE 0 END) "public_cost"
78
78
  FROM
79
79
  "${cur_table_name}"
80
- WHERE (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)))
81
-
80
+ WHERE
81
+ (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH))
82
+ AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH))
83
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
82
84
  GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,33,34
@@ -73,6 +73,8 @@
73
73
  WHEN ("line_item_line_item_type" <> 'SavingsPlanNegation') THEN "pricing_public_on_demand_cost" ELSE 0 END) "public_cost"
74
74
  FROM
75
75
  "${cur_table_name}"
76
- WHERE (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)))
77
-
76
+ WHERE
77
+ (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH))
78
+ AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH))
79
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
78
80
  GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34
@@ -21,5 +21,8 @@ CREATE OR REPLACE VIEW hourly_view AS
21
21
  , "sum"("line_item_usage_amount") "usage_quantity"
22
22
  FROM
23
23
  "${cur_table_name}"
24
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage')))
25
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
24
+ WHERE
25
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
26
+ AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage'))
27
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
28
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
@@ -21,5 +21,8 @@ CREATE OR REPLACE VIEW hourly_view AS
21
21
  , "sum"("line_item_usage_amount") "usage_quantity"
22
22
  FROM
23
23
  "${cur_table_name}"
24
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage')))
25
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
24
+ WHERE
25
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
26
+ AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage'))
27
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
28
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
@@ -21,5 +21,8 @@ CREATE OR REPLACE VIEW hourly_view AS
21
21
  , "sum"("line_item_usage_amount") "usage_quantity"
22
22
  FROM
23
23
  "${cur_table_name}"
24
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage')))
25
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
24
+ WHERE
25
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
26
+ AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage'))
27
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
28
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
@@ -21,5 +21,8 @@ CREATE OR REPLACE VIEW hourly_view AS
21
21
  , "sum"("line_item_usage_amount") "usage_quantity"
22
22
  FROM
23
23
  "${cur_table_name}"
24
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage')))
25
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
24
+ WHERE
25
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
26
+ AND ((("line_item_line_item_type" = 'Usage') OR ("line_item_line_item_type" = 'SavingsPlanCoveredUsage')) OR ("line_item_line_item_type" = 'DiscountedUsage'))
27
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
28
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
@@ -35,5 +35,8 @@ CREATE OR REPLACE VIEW resource_view AS
35
35
  , "sum"("line_item_unblended_cost") unblended_cost
36
36
  FROM
37
37
  "${cur_table_name}"
38
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> ''))
39
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
38
+ WHERE
39
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
40
+ AND (line_item_resource_id <> '')
41
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
42
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
@@ -35,5 +35,8 @@ CREATE OR REPLACE VIEW resource_view AS
35
35
  , "sum"("line_item_unblended_cost") unblended_cost
36
36
  FROM
37
37
  "${cur_table_name}"
38
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> ''))
39
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
38
+ WHERE
39
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
40
+ AND (line_item_resource_id <> '')
41
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
42
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
@@ -35,5 +35,8 @@ CREATE OR REPLACE VIEW resource_view AS
35
35
  , "sum"("line_item_unblended_cost") unblended_cost
36
36
  FROM
37
37
  "${cur_table_name}"
38
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> ''))
39
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
38
+ WHERE
39
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
40
+ AND (line_item_resource_id <> '')
41
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
42
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
@@ -35,5 +35,8 @@ CREATE OR REPLACE VIEW resource_view AS
35
35
  , "sum"("line_item_unblended_cost") unblended_cost
36
36
  FROM
37
37
  "${cur_table_name}"
38
- WHERE (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date) AND (line_item_resource_id <> ''))
39
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
38
+ WHERE
39
+ (((current_date - INTERVAL '30' DAY) <= line_item_usage_start_date)
40
+ AND (line_item_resource_id <> '')
41
+ AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2'))
42
+ GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
@@ -26,10 +26,12 @@ def cid_command(func):
26
26
  if len(ctx.args) % 2 != 0:
27
27
  print(f"Unknown extra argument, or an option without value {ctx.args}")
28
28
  exit(-1)
29
+ params = {}
29
30
  for i in range(0, len(ctx.args), 2):
30
- kwargs[ctx.args[i][2:].replace('-', '_')] = ctx.args[i+1]
31
+ key = ctx.args[i][2:].replace('-', '_')
32
+ params[key] = ctx.args[i+1]
33
+ set_parameters(params, all_yes=ctx.obj.all_yes)
31
34
 
32
- set_parameters(kwargs, all_yes=ctx.obj.all_yes)
33
35
  res = None
34
36
  try:
35
37
  res = func(ctx, **kwargs)
@@ -59,7 +61,7 @@ def cid_command(func):
59
61
 
60
62
  @click.group()
61
63
  @click.option('--profile_name', '--profile', help='AWS Profile name to use', default=None)
62
- @click.option('--region_name', help="AWS Region (default:'us-east-1')", default=None)
64
+ @click.option('--region_name', help="AWS Region", default=None)
63
65
  @click.option('--aws_access_key_id', help='', default=None)
64
66
  @click.option('--aws_secret_access_key', help='', default=None)
65
67
  @click.option('--aws_session_token', help='', default=None)
@@ -75,7 +77,6 @@ def main(ctx, **kwargs):
75
77
 
76
78
  ctx.obj = Cid(**kwargs)
77
79
 
78
-
79
80
  @click.option('-v', '--verbose', count=True)
80
81
  @click.option('-y', '--yes', help='confirm all', is_flag=True, default=False)
81
82
  @cid_command
@@ -125,6 +126,7 @@ def deploy(ctx, **kwargs):
125
126
  --cur-table-name TEXT CUR table name
126
127
  --quicksight-datasource-id TEXT QuickSight Datasource ARN (if not found one with provided Athena workgroup)
127
128
  --quicksight-datasource-role-arn TEXT IAM Role used for DataSource Creation (if not provided, will use the default QS Role). Must have access to Athena and S3 buckets.
129
+ --allow-buckets Comma separated list of buckets names to add to the default Cid QuickSight role
128
130
  --quicksight-user TEXT QuickSight user
129
131
  --dataset-{dataset_name}-id TEXT QuickSight dataset id for a specific dataset
130
132
  --view-{view_name}-{parameter} TEXT a custom parameter for a view creation, can use variable: {account_id}
@@ -135,6 +137,7 @@ def deploy(ctx, **kwargs):
135
137
  --resources TEXT CID resources yaml file or url
136
138
  --category TEXT Comma separated list of categories of dashboards (ex: foundational,advanced )
137
139
  --catalog TEXT Comma separated list of catalog files or urls (ex: foundational,advanced )
140
+ --theme TEXT A QuickSight Theme (CLASSIC|MIDNIGHT|SEASIDE|RAINIER)
138
141
  """
139
142
  ctx.obj.deploy(**kwargs)
140
143
 
@@ -200,6 +203,7 @@ def update(ctx, dashboard_id, force, recursive, **kwargs):
200
203
  \b
201
204
 
202
205
  --on-drift (show|override) Action if a drift of view and dataset is discovered. 'override' = override drift(will destroy customization) or 'show' (default) = show a diff. In Unattended mode (without terminal on-drift will have allways override behaviour)
206
+ --theme TEXT A QuickSight Theme (CLASSIC|MIDNIGHT|SEASIDE|RAINIER)
203
207
 
204
208
  """
205
209
  ctx.obj.update(dashboard_id, force=force, recursive=recursive, **kwargs)
@@ -45,7 +45,8 @@ class Cid():
45
45
  self.qs_url = 'https://{region}.quicksight.{domain}/sn/dashboards/{dashboard_id}'
46
46
  self.all_yes = kwargs.get('yes')
47
47
  self.verbose = kwargs.get('verbose')
48
- set_parameters(kwargs, self.all_yes)
48
+ # save main parameters to global parameters but do not override parameters that were set from outside
49
+ set_parameters({key: val for key, val in kwargs.items() if key.replace('_', '-') not in get_parameters()}, self.all_yes)
49
50
  self._logger = None
50
51
  self.catalog_urls = [
51
52
  'https://raw.githubusercontent.com/aws-samples/aws-cudos-framework-deployment/main/dashboards/catalog.yaml',
@@ -60,9 +61,11 @@ class Cid():
60
61
  'aws_session_token': None
61
62
  }
62
63
  for key in params.keys():
63
- value = get_parameters().get(key.replace('_', '-'))
64
- if value != None:
64
+ value = get_parameters().get(key.replace('_', '-'), '<NO VALUE>')
65
+ if value != '<NO VALUE>':
65
66
  params[key] = value
67
+ if get_parameters().get('region'):
68
+ params['region_name'] = get_parameters().get('region') # use region as a synonym of region_name
66
69
 
67
70
  print('Checking AWS environment...')
68
71
  try:
@@ -1300,11 +1303,11 @@ class Cid():
1300
1303
  if not role_arn:
1301
1304
  role_name = get_parameters().get('quicksight-datasource-role')
1302
1305
  if role_name:
1303
- role_arn = f'arn:aws:iam::{self.base.account_id}:role/{role_name}'
1306
+ role_arn = self.iam.get_role_arn(role_name)
1304
1307
 
1305
1308
  if not role_arn:
1306
1309
  quicksight_trusted_roles = list(self.iam.iterate_role_names(search="Roles[?AssumeRolePolicyDocument.Statement[?Principal.Service=='quicksight.amazonaws.com']].RoleName"))
1307
- #quicksight_trusted_roles = [role for role in quicksight_trusted_roles if role not in ('aws-quicksight-secretsmanager-role-v0')] # filter out irrelevant roles
1310
+ quicksight_trusted_roles = [role for role in quicksight_trusted_roles if role not in ('aws-quicksight-secretsmanager-role-v0')] # filter out irrelevant roles
1308
1311
  # TODO: filter only roles with Athena and S3 policies
1309
1312
  cid_role_name = 'CidCmdQuickSightDataSourceRole'
1310
1313
  choices = quicksight_trusted_roles
@@ -1321,25 +1324,36 @@ class Cid():
1321
1324
  default=default,
1322
1325
  )
1323
1326
  if "<ADD NEW ROLE>" in choice or choice == cid_role_name: # Create or update role
1324
- # TODO: allow customer add buckets
1327
+ # TODO: get buckets from dashboard parameters
1325
1328
  buckets = [
1326
- f'cid-{self.base.account_id}-share',
1329
+ f'cid-{self.base.account_id}-shared',
1330
+ f'cid-{self.base.account_id}-data-exports',
1327
1331
  f'cid-data-{self.base.account_id}',
1328
1332
  f'costoptimizationdata{self.base.account_id}',
1329
1333
  ]
1334
+ additional_buckets = get_parameters().get('allow-buckets')
1335
+ if additional_buckets:
1336
+ buckets += [bucket.strip().replace('{account_id}', self.base.account_id) for bucket in additional_buckets.split(',')]
1337
+
1338
+ databases = set([
1339
+ "optimization_data",
1340
+ "cid_data_collection",
1341
+ "cid_data_export", # prefix for data-exports hardcoded here
1342
+ self.athena.DatabaseName,
1343
+ ])
1330
1344
  role_name = self.iam.ensure_data_source_role_exists(
1331
1345
  role_name=cid_role_name,
1332
- database=self.athena.DatabaseName,
1346
+ databases=databases,
1333
1347
  workgroup=self.athena.WorkGroup,
1334
1348
  buckets=buckets,
1335
1349
  output_location_bucket = self.athena.workgroup_output_location().split('/')[2],
1336
1350
  )
1337
1351
  cid_print(f'Role {role_name} was updated. https://console.aws.amazon.com/iam/home?#/roles/details/{role_name}')
1338
- role_arn = f'arn:aws:iam::{self.base.account_id}:role/{role_name}'
1339
- elif 'USE DEFAULT QuickSight ROLE' in choice:
1352
+ role_arn = self.iam.get_role_arn(role_name)
1353
+ elif 'USE DEFAULT QuickSight ROLE' in choice or choice == 'default':
1340
1354
  role_arn = None
1341
1355
  else:
1342
- role_arn = choice
1356
+ role_arn = self.iam.get_role_arn(choice)
1343
1357
 
1344
1358
  athena_datasource = self.qs.create_data_source(
1345
1359
  athena_workgroup=self.athena.WorkGroup,
@@ -1677,8 +1691,8 @@ class Cid():
1677
1691
  pass
1678
1692
  else:
1679
1693
  self.athena.execute_query(view_query)
1680
- assert self.athena.wait_for_view(view_name), f"Failed to create a view {view_name}"
1681
- logger.info(f'View "{view_name}" created')
1694
+ assert self.athena.wait_for_view(view_name), f"Failed to create a view {view_name}"
1695
+ logger.info(f'View "{view_name}" created')
1682
1696
 
1683
1697
  if 'crawler' in view_definition:
1684
1698
  if not ('CREATE EXTERNAL TABLE' in view_query.upper() or view_definition.get('type') == 'Glue_Table'):
@@ -1710,7 +1724,7 @@ class Cid():
1710
1724
  )
1711
1725
 
1712
1726
  if not crawler_role.startswith('arn:'):
1713
- crawler_role_arn = f"arn:aws:iam::{self.base.account_id}:role/{crawler_role}"
1727
+ crawler_role_arn = f"arn:{self.base.partition}:iam::{self.base.account_id}:role/{crawler_role}"
1714
1728
  else:
1715
1729
  crawler_role_arn = crawler_role
1716
1730
  params = {
@@ -73,29 +73,28 @@ class Athena(CidBase):
73
73
  except Exception as exc:
74
74
  if 'AccessDeniedException' in str(exc):
75
75
  logger.warning(f'{type(exc)} - Missing athena:GetDatabase permission. Cannot verify existence of {self._DatabaseName} in {self.CatalogName}. Hope you have it there.')
76
- return self._DatabaseName
77
- raise
76
+ else:
77
+ raise
78
+ return self._DatabaseName
78
79
  # Get AWS Athena databases
79
80
  athena_databases = self.list_databases()
80
81
 
81
- # Select default database if present
82
+ # check if we have a default database
82
83
  default_databases = [database for database in athena_databases if database['Name'] == self.defaults.get('DatabaseName')]
83
- if len(default_databases):
84
- # Silently choose an existing default database
85
- self._DatabaseName = default_databases.pop().get('Name')
86
- else:
87
- # Ask user
88
- choices = [d['Name'] for d in athena_databases]
89
- if self.defaults.get('DatabaseName') not in choices:
90
- choices.append(self.defaults.get('DatabaseName') + ' (CREATE NEW)')
91
- self._DatabaseName = get_parameter(
92
- param_name='athena-database',
93
- message="Select AWS Athena database to use",
94
- choices=choices,
95
- )
96
- if self._DatabaseName.endswith( ' (CREATE NEW)'):
97
- self._DatabaseName = self.defaults.get('DatabaseName')
98
- self.query(f'CREATE DATABASE {self._DatabaseName}')
84
+
85
+ # Ask user
86
+ choices = [d['Name'] for d in athena_databases]
87
+ if self.defaults.get('DatabaseName') not in choices:
88
+ choices.append(self.defaults.get('DatabaseName') + ' (CREATE NEW)')
89
+ self._DatabaseName = get_parameter(
90
+ param_name='athena-database',
91
+ message="Select AWS Athena database to use",
92
+ choices=choices,
93
+ default=default_databases[0]['Name'] if default_databases else None,
94
+ )
95
+ if self._DatabaseName.endswith( ' (CREATE NEW)'):
96
+ self._DatabaseName = self.defaults.get('DatabaseName')
97
+ self.query(f'CREATE DATABASE {self._DatabaseName}')
99
98
  logger.info(f'Using Athena database: {self._DatabaseName}')
100
99
  return self._DatabaseName
101
100
 
@@ -4,7 +4,7 @@ import json
4
4
  import logging
5
5
 
6
6
  from cid.base import CidBase
7
- from cid.utils import get_parameter, get_parameters
7
+ from cid.utils import get_parameter, get_parameters, cid_print
8
8
  from cid.exceptions import CidCritical
9
9
 
10
10
  logger = logging.getLogger(__name__)
@@ -135,8 +135,9 @@ class CUR(CidBase):
135
135
  self.athena.query(f'ALTER TABLE {self.table_name} ADD COLUMNS ({column} {column_type})')
136
136
  except (self.athena.client.exceptions.ClientError, CidCritical) as exc:
137
137
  raise CidCritical(f'Column {column} is not found in CUR and we were unable to add it. Please check FAQ.') from exc
138
- self._metadata = self.athena.get_table_metadata(self.table_name) # refresh table metadata
139
- logger.critical(f"Column '{column}' was added to CUR ({self.table_name}). Please make sure crawler do not override that columns. Crawler='{crawler_name}'")
138
+ # table takes time to update so just adding column to cached data
139
+ self._metadata.get('Columns', []).append({'Name': column, 'Type': column_type})
140
+ cid_print(f"Column '{column}' was added to CUR ({self.table_name}).")
140
141
  return
141
142
 
142
143
  # if table cannot be updated, check if it is ri/sp case - let's hope dashboard views can handle it:
@@ -145,7 +146,7 @@ class CUR(CidBase):
145
146
  return
146
147
 
147
148
  # if a required column is not there and not ri/sp -> stop
148
- logger.critical(f"Column '{column}' is not in ({self.table_name}). Cannot continue")
149
+ logger.critical(f"Column '{column}' is not in ({self.table_name}). Cannot continue.")
149
150
 
150
151
 
151
152
  def table_is_cur(self, table: dict=None, name: str=None, return_reason: bool=False) -> bool:
@@ -176,6 +177,8 @@ class CUR(CidBase):
176
177
  self._metadata = self.athena.get_table_metadata(table_name)
177
178
  except self.athena.client.exceptions.ResourceNotFoundException as exc:
178
179
  raise CidCritical(f'Provided cur-table-name "{table_name}" is not found. Please make sure the table exists.') from exc
180
+ except self.athena. athena.exceptions.MetadataException as exc:
181
+ raise CidCritical(f'Provided cur-table-name "{table_name}" is not found in database "{self.athena.DatabaseName}". Please make sure the table exists. Also if you use LakeFormation, make sure that the user is granted with read rights.') from exc
179
182
  res, message = self.table_is_cur(table=self._metadata, return_reason=True)
180
183
  if not res:
181
184
  raise CidCritical(f'Table {table_name} does not look like CUR. {message}')
@@ -8,7 +8,7 @@ import logging
8
8
  import boto3
9
9
  from tqdm import tqdm
10
10
 
11
- from cid.exceptions import CidCritical
11
+ from cid.exceptions import CidCritical, CidError
12
12
  from cid.base import CidBase
13
13
  from cid.utils import get_parameter
14
14
 
@@ -61,13 +61,13 @@ class IAM(CidBase):
61
61
  "Sid": "AllowListBucket",
62
62
  "Effect": "Allow",
63
63
  "Action": ["s3:ListBucket"],
64
- "Resource": [f"arn:aws:s3:::{s3bucket}"]
64
+ "Resource": [f"arn:{self.partition}:s3:::{s3bucket}"]
65
65
  },
66
66
  {
67
67
  "Sid": "AllowReadFromBucket",
68
68
  "Effect": "Allow",
69
69
  "Action": [ "s3:GetObject"],
70
- "Resource": [f"arn:aws:s3:::{s3bucket}/*"]
70
+ "Resource": [f"arn:{self.partition}:s3:::{s3bucket}/*"]
71
71
  },
72
72
  {
73
73
  "Sid": "AllowGlueActions",
@@ -113,7 +113,7 @@ class IAM(CidBase):
113
113
  policy_merge_mode='MERGE_RESOURCES',
114
114
  managed_policies=[]
115
115
  )
116
- def ensure_data_source_role_exists(self, role_name, database, workgroup, kms_key_arns='', buckets=[], output_location_bucket=None):
116
+ def ensure_data_source_role_exists(self, role_name, databases, workgroup, kms_key_arns='', buckets=[], output_location_bucket=None):
117
117
  ''' Create or update a role specifically for a QS Datasource
118
118
  '''
119
119
  return self.ensure_role_with_policy(
@@ -151,14 +151,16 @@ class IAM(CidBase):
151
151
  "glue:GetPartition",
152
152
  "glue:GetPartitions",
153
153
  "glue:GetDatabases",
154
+ "glue:GetDatabase",
154
155
  "glue:GetTable",
155
156
  "glue:GetTables",
156
157
  ],
157
158
  "Resource": [
158
159
  f"arn:{self.partition}:glue:{self.region}:{self.account_id}:catalog",
159
- f"arn:{self.partition}:glue:{self.region}:{self.account_id}:database/{database}",
160
- f"arn:{self.partition}:glue:{self.region}:{self.account_id}:table/{database}/*",
161
- ],
160
+ ] + sum([
161
+ [f"arn:{self.partition}:glue:{self.region}:{self.account_id}:database/{database}",
162
+ f"arn:{self.partition}:glue:{self.region}:{self.account_id}:table/{database}/*" ]
163
+ for database in databases ], []),
162
164
  },
163
165
  {
164
166
  "Sid": "AllowAthena",
@@ -175,7 +177,6 @@ class IAM(CidBase):
175
177
  ],
176
178
  "Resource": [
177
179
  f"arn:{self.partition}:athena:{self.region}:{self.account_id}:datacatalog/AwsDataCatalog", # TODO: check if this can be variable?
178
- f"arn:{self.partition}:athena:{self.region}:{self.account_id}:database/{database}",
179
180
  f"arn:{self.partition}:athena:{self.region}:{self.account_id}:workgroup/{workgroup}",
180
181
  ]
181
182
  },
@@ -323,6 +324,22 @@ class IAM(CidBase):
323
324
  except self.client.exceptions.ClientError as exc:
324
325
  logger.warning('Failed to read available IEM roles: {exc}. Most likely not fatal.')
325
326
 
327
+ def get_role_arn(self, role_name:str) -> str:
328
+ """ Get role arn, and try the best guess if no permissions
329
+ """
330
+ try:
331
+ return self.client.get_role(RoleName=role_name)['Role']['Arn']
332
+ except self.client.exceptions.NoSuchEntityException:
333
+ raise CidError(f"Role '{role_name}' does not exist.")
334
+ except self.client.exceptions.ClientError as exc:
335
+ if "AccessDenied" in str(exc):
336
+ logger.debug('Got access denied for describing role. Try the best guess')
337
+ if role_name.startswith('aws-quicksight-service-role'):
338
+ return f'arn:aws:iam::{self.account_id}:role/service-role/{role_name}'
339
+ else:
340
+ return f'arn:aws:iam::{self.account_id}:role/{role_name}'
341
+ raise CidError(f"An error occurred: {exc}")
342
+
326
343
  def ensure_role_does_not_exist(self, role_name):
327
344
  """ Remove a role and all policies if they are not used in other roles
328
345
  """
@@ -1335,10 +1335,10 @@ class QuickSight(CidBase):
1335
1335
  'Name': definition.get('name'),
1336
1336
  'ValidationStrategy': {'Mode': 'LENIENT'},
1337
1337
  }
1338
- theme = definition.get('theme')
1338
+ theme = get_parameters().get('theme') or definition.get('theme')
1339
1339
  if theme:
1340
1340
  if not theme.startswith('arn:'):
1341
- theme_arn = 'arn:aws:quicksight::aws:theme/' + theme
1341
+ theme_arn = f'arn:{self.partition}:quicksight::aws:theme/' + theme
1342
1342
  else:
1343
1343
  raise NotImplementedError('Only standard themes are supported now.')
1344
1344
  create_parameters['ThemeArn'] = theme_arn
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cid-cmd
3
- Version: 0.3.2
3
+ Version: 0.3.8
4
4
  Summary: Cloud Intelligence Dashboards deployment helper tool
5
5
  Home-page: https://github.com/aws-samples/aws-cudos-framework-deployment
6
6
  Author: AWS CUDOS Team
@@ -1 +0,0 @@
1
- __version__ = '0.3.2'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes