|
| 1 | +# Handy BASH scrips for working with Lacework |
| 2 | + |
| 3 | +## lw_aws_inventory.sh |
| 4 | +Script for estimating license vCPUs in an AWS environment. It leverages the AWS CLI and leverages by default the default profile that’s either configured using environment variables or configuration files in the ~/.aws folder. The script provides output in a CSV format to be imported into a spreadsheet, as well as an easy-to-read summary. |
| 5 | + |
| 6 | +Note the following about the script: |
| 7 | +* It requires AWS CLI v2 to run |
| 8 | +* It does not work on Windows |
| 9 | +* It has only been verified to work on Mac and Linux based systems |
| 10 | +* It works great in a cloud shell |
| 11 | + |
| 12 | +The output from running the script can look as follows: |
| 13 | +``` |
| 14 | +./lw_aws_inventory.sh -p admin-account -o -r us-east-1 |
| 15 | +Profile, Account ID, Regions, EC2 Instances, EC2 vCPUs, ECS Fargate Clusters, ECS Fargate Running Containers/Tasks, ECS Fargate CPU Units, ECS Fargate License vCPUs, Lambda Functions, MB Lambda Memory, Lambda License vCPUs, Total vCPUSs |
| 16 | +sandbox-1, 123456789012, us-east-1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2 |
| 17 | +sandbox-2, 234567890123, us-east-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 18 | +logging, 345678901234, us-east-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 19 | +###################################################################### |
| 20 | +Lacework inventory collection complete. |
| 21 | +
|
| 22 | +Organizations Analyzed: 1 |
| 23 | +Accounts Analyzed: 3 |
| 24 | +
|
| 25 | +EC2 Information |
| 26 | +==================== |
| 27 | +EC2 Instances: 2 |
| 28 | +EC2 vCPUs: 2 |
| 29 | +
|
| 30 | +Fargate Information |
| 31 | +==================== |
| 32 | +ECS Clusters: 0 |
| 33 | +ECS Fargate Running Tasks: 0 |
| 34 | +ECS Fargate Container CPU Units: 0 |
| 35 | +ECS Fargate vCPUs: 0 |
| 36 | +
|
| 37 | +Lambda Information |
| 38 | +==================== |
| 39 | +Lambda Functions: 0 |
| 40 | +MB Lambda Memory: 0 |
| 41 | +Lambda License vCPUs: 0 |
| 42 | +
|
| 43 | +License Summary |
| 44 | +==================== |
| 45 | + EC2 vCPUs: 2 |
| 46 | ++ ECS Fargate vCPUs: 0 |
| 47 | ++ Lambda License vCPUs: 0 |
| 48 | +---------------------------- |
| 49 | += Total vCPUs: 2 |
| 50 | +``` |
| 51 | +The following options can be used to modify how the script is run: |
| 52 | +### Specify one or more account profiles to scan using -p parameter |
| 53 | +``` |
| 54 | +./lw_aws_inventory.sh -p default,lw-customerdemo |
| 55 | +``` |
| 56 | +### Specify what regions to scan, to speed up scanning or avoid restricted regions |
| 57 | +``` |
| 58 | +./lw_aws_inventory.sh -r us-east-1,us-east-2 |
| 59 | +``` |
| 60 | +### Scan all accounts in an AWS Organization |
| 61 | +``` |
| 62 | +./lw_aws_inventory.sh -o |
| 63 | +``` |
| 64 | +This will leverage the OrganizationAccountAccessRole to scan all accounts in an organization. |
| 65 | + |
| 66 | +## lw_gcp_inventory.sh |
| 67 | +Script for estimating license vCPUs in a GCP environment, based on folder, project or organization level. |
| 68 | + |
| 69 | +Note the following about the script: |
| 70 | +* It does not work on Windows |
| 71 | +* It has only been verified to work on Mac and Linux based systems |
| 72 | +* It works great in a cloud shell |
| 73 | + |
| 74 | +``` |
| 75 | +$ ./lw_gcp_inventory.sh -help |
| 76 | +Usage: ./lw_gcp_inventory.sh [-f folder] [-o organization] [-p project] |
| 77 | +Any single scope can have multiple values comma delimited, but multiple scopes cannot be defined. |
| 78 | +``` |
| 79 | + |
| 80 | +By default, the script will scan any project that the user has access to: |
| 81 | +``` |
| 82 | +$ ./lw_gcp_inventory.sh |
| 83 | +"Project", "VM Count", "vCPUs" |
| 84 | +"projects/project-one", 2, 8 |
| 85 | +"projects/project-two", 3, 12 |
| 86 | +########################################## |
| 87 | +Lacework inventory collection complete. |
| 88 | +
|
| 89 | +License Summary: |
| 90 | +================================================ |
| 91 | +Number of VMs, including standard GKE: 5 |
| 92 | +vCPUs: 20 |
| 93 | +``` |
| 94 | + |
| 95 | +The scope of the scan can be further refined using the -f, -o or -p parameters: |
| 96 | +``` |
| 97 | +$ ./lw_gcp_inventory.sh -p project-one,project-two |
| 98 | +"Project", "VM Count", "vCPUs" |
| 99 | +"projects/project-one", 2, 8 |
| 100 | +"projects/project-two", 3, 12 |
| 101 | +########################################## |
| 102 | +Lacework inventory collection complete. |
| 103 | +
|
| 104 | +License Summary: |
| 105 | +================================================ |
| 106 | +Number of VMs, including standard GKE: 5 |
| 107 | +vCPUs: 20 |
| 108 | +``` |
| 109 | + |
| 110 | +## lw_azure_inventory.sh |
| 111 | +Script for estimating license vCPUs in an Azure environment, based on folder, project or organization level. |
| 112 | + |
| 113 | +Note the following about the script: |
| 114 | +* It does not work on Windows |
| 115 | +* It has only been verified to work on Mac and Linux based systems |
| 116 | +* It works great in a cloud shell |
| 117 | + |
| 118 | +``` |
| 119 | +./lw_azure_inventory.sh -help |
| 120 | +Usage: ./lw_azure_inventory.sh [-m management_group] [-s subscription] |
| 121 | +Any single scope can have multiple values comma delimited, but multiple scopes cannot be defined. |
| 122 | +``` |
| 123 | + |
| 124 | +By default, the script will scan any subscriptions the user has configured access to: |
| 125 | +``` |
| 126 | +$ ./lw_azure_inventory.sh -m b448f327-c977-4cb8-9c27-09cfaa781bb9 |
| 127 | +resource-graph extension already present... |
| 128 | +Building Azure VM SKU to vCPU map... |
| 129 | +Map built successfully. |
| 130 | +Load subscriptions |
| 131 | +Load VMs |
| 132 | +Load VMSS |
| 133 | +"Subscription ID", "Subscription Name", "VM Instances", "VM vCPUs", "VM Scale Sets", "VM Scale Set Instances", "VM Scale Set vCPUs", "Total Subscription vCPUs" |
| 134 | +"1215ba55...", "Subscription Number One", 2, 4, 0, 0, 0, 4 |
| 135 | +"72165fcf...", "Subscription Number Two", 1, 2, 0, 0, 0, 2 |
| 136 | +########################################## |
| 137 | +Lacework inventory collection complete. |
| 138 | +
|
| 139 | +VM Summary: |
| 140 | +=============================== |
| 141 | +VM Instances: 3 |
| 142 | +VM vCPUS: 6 |
| 143 | +
|
| 144 | +VM Scale Set Summary: |
| 145 | +=============================== |
| 146 | +VM Scale Sets: 0 |
| 147 | +VM Scale Set Instances: 0 |
| 148 | +VM Scale Set vCPUs: 0 |
| 149 | +
|
| 150 | +License Summary |
| 151 | +=============================== |
| 152 | + VM vCPUS: 6 |
| 153 | ++ VM Scale Set vCPUs: 0 |
| 154 | +------------------------------- |
| 155 | +Total vCPUs: 6 |
| 156 | +``` |
| 157 | + |
| 158 | +The scope can further be refined by specifying management groups or subscriptions. |
| 159 | +### Specify subscriptions to scan |
| 160 | +``` |
| 161 | +$ ./lw_azure_inventory.sh -s 1215ba55,72165fcf |
| 162 | +``` |
| 163 | +### Specify management group to scan |
| 164 | +``` |
| 165 | +$ ./lw_azure_inventory.sh -m mymanagementgroup,myothermanagementgroup |
| 166 | +``` |
0 commit comments