|
| 1 | +# Command Tool CID-CMD |
| 2 | + |
| 3 | +Cloud Intelligence Dashboards provides a python tool for installation and upgrade of Dashboards. This tool can also export dashboards to deployable artifacts including QuickSight Dashboards, Athena Views, Glue Tables etc. |
| 4 | + |
| 5 | +We recommend cid-cmd tool via [AWS CloudShell](https://console.aws.amazon.com/cloudshell/home), but you can use it from any terminal where you typically run aws commands. |
| 6 | + |
| 7 | +CID is also provided in a form of CloudFormation templates. See detailed instructions in the [Well Architected Labs](https://catalog.workshops.aws/awscid/en-US/dashboards/foundational/cudos-cid-kpi/deploy) site. |
| 8 | + |
| 9 | + |
| 10 | +## Before you start |
| 11 | +1. :heavy_exclamation_mark: Complete the prerequisites for respective dashboard. |
| 12 | +2. :heavy_exclamation_mark: [Specifying a Query Result Location Using a Workgroup](https://docs.aws.amazon.com/athena/latest/ug/querying.html#query-results-specify-location-workgroup) |
| 13 | +3. :heavy_exclamation_mark: Make sure QuickSight [Enterprise edition](https://aws.amazon.com/premiumsupport/knowledge-center/quicksight-enterprise-account/) is activated. |
| 14 | + |
| 15 | +## Command line tool cid-cmd |
| 16 | + |
| 17 | +#### Demo: Deployment of Dashboards with cid-cmd tool |
| 18 | + |
| 19 | + [](https://asciinema.org/a/467770) |
| 20 | + |
| 21 | +#### Install |
| 22 | + |
| 23 | +1. Launch [AWS CloudShell](https://console.aws.amazon.com/cloudshell/home) or your local shell |
| 24 | + |
| 25 | + Automation requires Python 3 |
| 26 | + |
| 27 | +2. Make sure you have the latest pip package installed |
| 28 | + ```bash |
| 29 | + python3 -m ensurepip --upgrade |
| 30 | + ``` |
| 31 | + |
| 32 | +4. Install CID Python automation PyPI package |
| 33 | + ```bash |
| 34 | + pip3 install --upgrade cid-cmd |
| 35 | + ``` |
| 36 | + |
| 37 | +#### Dashboard Deployment |
| 38 | + |
| 39 | +```bash |
| 40 | +cid-cmd deploy |
| 41 | +``` |
| 42 | + |
| 43 | + |
| 44 | +#### Update existing Dashboards |
| 45 | +Update only Dashboard |
| 46 | +```bash |
| 47 | +cid-cmd update |
| 48 | +``` |
| 49 | +Update dashboard and all dependencies (Datasets and Athena View). WARNING: this will override any customization of SQL files and Datasets. |
| 50 | +```bash |
| 51 | +cid-cmd update --force --recursive |
| 52 | +``` |
| 53 | + |
| 54 | +#### Show Dashboard Status |
| 55 | +Show dashboards status |
| 56 | + |
| 57 | +```bash |
| 58 | +cid-cmd status |
| 59 | +``` |
| 60 | +[<img width="558" alt="status" src="https://github.com/aws-samples/aws-cudos-framework-deployment/assets/82834333/cae2015f-0f81-4593-80b3-c67ec1200fcd">](https://www.youtube.com/watch?v=ivr1MoGaApM) |
| 61 | + |
| 62 | + |
| 63 | +#### Share QuickSight resources |
| 64 | +```bash |
| 65 | +cid-cmd share |
| 66 | +``` |
| 67 | + |
| 68 | +#### Initialize Amazon QuickSight |
| 69 | +One time action to initialize Amazon QuickSight Enterprise Edition. |
| 70 | + |
| 71 | +```bash |
| 72 | +cid-cmd init-qs |
| 73 | +``` |
| 74 | + |
| 75 | +#### Initialize CUR |
| 76 | +One time action to initialize Athena table and Crawler from s3 with CUR data. Currently only CUR1 supported. |
| 77 | + |
| 78 | +```bash |
| 79 | +cid-cmd init-cur |
| 80 | +``` |
| 81 | + |
| 82 | +#### Create CUR proxy |
| 83 | +There are 2 CUR formats that `cid-cmd` supports. CUR1 and CUR2 have slightly different fields structure. Each dashboard can be developed using CUR2 or CUR1, but on installation `cid-cmd` will deploy a special Athena View "CUR proxy". This View will play a role of compatibility layer between the CUR version used by Dashboard and available CUR. This View can be extended as new dashboard request CUR fields. |
| 84 | + |
| 85 | +Please note that Cost Allocation Tags and Cost Categories are not present in CUR Proxy by default. You will need to add these fields by modifying CUR Proxy in Athena or using `cid-cmd` tool: |
| 86 | + |
| 87 | +For CUR2 proxy (using CUR1 data as source) |
| 88 | +```bash |
| 89 | +cid-cmd create-cur-proxy -vv \ |
| 90 | + --cur-version '2' \ |
| 91 | + --cur-table-name 'mycur1' \ |
| 92 | + --athena-workgroup 'primary' \ |
| 93 | + --fields "resource_tags['user_cost_center'],resource_tags['user_owner']" |
| 94 | +``` |
| 95 | + |
| 96 | +For CUR1 proxy (using CUR2 data as source) |
| 97 | +```bash |
| 98 | +cid-cmd create-cur-proxy -vv \ |
| 99 | + --cur-version '1' \ |
| 100 | + --cur-table-name 'mycur2' \ |
| 101 | + --athena-workgroup 'primary' \ |
| 102 | + --fields "resource_tags_user_cost_center,resource_tags_user_owner" |
| 103 | +``` |
| 104 | + |
| 105 | + |
| 106 | +#### Delete Dashboard and all dependencies unused by other |
| 107 | +Delete Dashboards and all dependencies unused by other CID-managed dashboards.(including QuickSight datasets, Athena views and tables) |
| 108 | +```bash |
| 109 | +cid-cmd delete |
| 110 | +``` |
| 111 | + |
| 112 | +Delete Command Options: |
| 113 | +``` |
| 114 | + --dashboard-id TEXT QuickSight dashboard id |
| 115 | + --athena-database TEXT Athena database |
| 116 | +``` |
| 117 | +
|
| 118 | +#### Export |
| 119 | +The command `export` lets you download or share a customized dashboard with another AWS Account. It takes the QuickSight Analysis as an input and generates all the assets needed to deploy your Analysis into another AWS Account. This command will generate a yaml file with a description of the Dashboard and all required Datasets. Also this command generates a QuickSight Template in the current AWS Account that can be used for Dashboard deployment in other accounts. The resource file can be used with all other cid commands. Both accounts must have relevant Athena Views and Tables. |
| 120 | +
|
| 121 | +Export from account A: |
| 122 | +``` |
| 123 | +cid-cmd export |
| 124 | +``` |
| 125 | +
|
| 126 | +Deployment to account B: |
| 127 | +``` |
| 128 | +cid-cmd deploy --resources ./mydashboard.yaml |
| 129 | +``` |
| 130 | +
|
| 131 | +#### See available commands and command line options |
| 132 | +``` |
| 133 | +cid-cmd --help |
| 134 | +``` |
| 135 | +
|
| 136 | +#### CSV to Athena View |
| 137 | +Generate and SQL file for Athena View for CSV file |
| 138 | +
|
| 139 | +``` |
| 140 | +cid-cmd csv2view --input my_mapping.csv --name my_mapping |
| 141 | +``` |
| 142 | +This command generates a SQL file that you can execute. Please mind [Athena Service Limit for Query Size](https://docs.aws.amazon.com/athena/latest/ug/service-limits.html#service-limits-query-string-length). |
| 143 | +
|
| 144 | +
|
| 145 | +
|
| 146 | +## Troubleshooting and Support |
| 147 | +If you experience unexpected behaviour of the `cid-cmd` script please run `cid-cmd` in debug mode: |
| 148 | +
|
| 149 | +```bash |
| 150 | +cid-cmd -vv [command] |
| 151 | +``` |
| 152 | + |
| 153 | +This will produce a log file in the same directory that were at the tile of launch of cid-cmd. |
| 154 | + |
| 155 | +:heavy_exclamation_mark:Inspect the produced debug log for any sensitive information and anonymize it. |
| 156 | + |
| 157 | +We encourage you to open [new issue](https://github.com/aws-samples/aws-cudos-framework-deployment/issues/new) with description of the problem and attached debug log file. |
0 commit comments