Skip to content

Commit

Permalink
Demo data revamp 202403 (#72)
Browse files Browse the repository at this point in the history
* update

* update

* update

* aws

* update

* update

* progress

* update

* readme

* readme

* update

* update

* update

* update

* update

* update

* update

* update

* ip

* update

* update

* update

* finish

* update

* update

* update

* Update CCO Demo Data (#70)

Co-authored-by: XOmniverse <[email protected]>

* update

* update

* update

* update

* update

* update

* update

* update

* up

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: XOmniverse <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2024
1 parent 38bbf70 commit 50c344d
Show file tree
Hide file tree
Showing 90 changed files with 64,179 additions and 33,176 deletions.
5 changes: 5 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
BUNDLE_PATH: "bundle"
BUNDLE_DEPLOYMENT: "true"
BUNDLE_JOBS: "4"
BUNDLE_WITHOUT: "documentation"
36 changes: 15 additions & 21 deletions .github/workflows/update_demo_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,33 @@ on:

jobs:
update-demo-data:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: task/update-cco-demo-data

- name: Set up local Git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Setup Node.js
uses: actions/setup-node@v2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Install underscore library
run: npm install underscore --legacy-peer-deps
- name: Configure Ruby Environment
run: bundle install --without documentation --path bundle

- name: Run the update script
run: bash ./update_demo_data.sh
run: |
mkdir -p flexera/data/aws
mkdir -p flexera/data/azure
mkdir -p flexera/data/google
ruby update_demo_data.rb
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit-message: "Update CCO Demo Data"
title: "Update CCO Demo Data"
body: "Updated CCO Demo from GitHub Actions Workflow [${{ github.workflow }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
branch: "task/update-cco-demo-data"
delete-branch: true
labels: "automation, data"

- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
file_pattern: 'flexera/data/aws/*.json flexera/data/azure/*.json flexera/data/google/*.json'
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.3
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem "rake", "~> 13.1.0"
gem "json", "~> 2.7"
gem "danger", "~> 9.4"
gem "danger-textlint", "~> 2.0.4"
gem "danger-prose", "~> 2.0.7"
gem "danger-rubocop", "~> 0.12.0"
gem "pry", "~> 0.14.2"
gem "rb-readline", "~> 0.5.5"
gem "mdl", "~> 0.13.0"
143 changes: 143 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
chef-utils (18.4.2)
concurrent-ruby
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
coderay (1.1.3)
colored2 (3.1.2)
concurrent-ruby (1.2.3)
cork (0.3.0)
colored2 (~> 3.1)
danger (9.4.3)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 3.0)
faraday-http-cache (~> 2.0)
git (~> 1.13)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (>= 4.0)
terminal-table (>= 1, < 4)
danger-plugin-api (1.0.0)
danger (> 2.0)
danger-prose (2.0.7)
danger
danger-rubocop (0.12.0)
danger
rubocop (~> 1.0)
danger-textlint (2.0.4)
danger-plugin-api (~> 1.0)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-net_http (3.1.0)
net-http
ffi (1.16.3-x64-mingw32)
ffi-win32-extensions (1.0.4)
ffi
git (1.19.1)
addressable (~> 2.8)
rchardet (~> 1.8)
json (2.7.1)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
mdl (0.13.0)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.1)
mixlib-cli (~> 2.1, >= 2.1.1)
mixlib-config (>= 2.2.1, < 4)
mixlib-shellout
method_source (1.0.0)
mixlib-cli (2.1.8)
mixlib-config (3.0.27)
tomlrb
mixlib-shellout (3.2.7)
chef-utils
mixlib-shellout (3.2.7-universal-mingw32)
chef-utils
ffi-win32-extensions (~> 1.0.3)
win32-process (~> 0.9)
wmi-lite (~> 1.0)
nap (1.1.0)
net-http (0.4.1)
uri
no_proxy_fix (0.1.2)
octokit (8.1.0)
base64
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.4)
racc (1.7.3)
rainbow (3.1.1)
rake (13.1.0)
rb-readline (0.5.5)
rchardet (1.8.0)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.61.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.1)
parser (>= 3.3.0.4)
ruby-progressbar (1.13.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tomlrb (2.0.3)
unicode-display_width (2.5.0)
uri (0.13.0)
win32-process (0.10.0)
ffi (>= 1.0.0)
wmi-lite (1.0.7)

PLATFORMS
ruby
x64-mingw32

DEPENDENCIES
danger (~> 9.4)
danger-prose (~> 2.0.7)
danger-rubocop (~> 0.12.0)
danger-textlint (~> 2.0.4)
json (~> 2.7)
mdl (~> 0.13.0)
pry (~> 0.14.2)
rake (~> 13.1.0)
rb-readline (~> 0.5.5)

BUNDLED WITH
2.2.16
6 changes: 3 additions & 3 deletions flexera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ These policies are intended to emulate their counterparts in the policy catalog

## How To Use

Upload the desired policies to your demo environment in Flexera One and apply. The policies require no credentials and will automatically pull demo data from this repository. Allow ~24 hours for this demo data to be reflected in Flexera One.
Upload the desired policies to your demo environment in Flexera One and apply. The policies require no credentials and will automatically pull demo data from this repository's `./flexera/data` directory in the `task/update-cco-demo-data` branch. Allow ~24 hours for this demo data to be reflected in Flexera One.

## Technical Details

Expand All @@ -17,5 +17,5 @@ Upload the desired policies to your demo environment in Flexera One and apply. T

## Data Generation

- The same-named .js files in the data folder were used to generate the demo data and can be modified and used to generate new data as needed.
- The update_all.sh bash script in the data folder can be run to update the demo data all at once. This script requires that the user have node.js installed so that the node command can be used to run the scripts.
- The `./update_demo_data.rb` script is used to generate the demo data.
- The `Update Demo Data` Github workflow runs on a weekly cadence to execute the script and update the demo data.
76 changes: 44 additions & 32 deletions flexera/aws/aws_delete_old_snapshots.pt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ name "AWS Old Snapshots [Demo]"
rs_pt_ver 20180301
type "policy"
short_description "Demo policy for generating recommendations. See [README](https://github.com/flexera-public/optima-tools/tree/master/flexera/) for more information."
long_description ""
category "Cost"
severity "low"
default_frequency "daily"
default_frequency "weekly"
info(
version: "6.2",
version: "8.0",
provider: "AWS",
service: "Storage",
policy_set: "Old Snapshots",
Expand All @@ -21,7 +22,7 @@ datasource "ds_snapshots_cost_mapping" do
request do
verb "GET"
host "raw.githubusercontent.com"
path "/flexera-public/optima-tools/master/flexera/data/aws/aws_delete_old_snapshots.json"
path "/flexera-public/optima-tools/task/update-cco-demo-data/flexera/data/aws/aws_delete_old_snapshots.json"
header "User-Agent", "RS Policies"
end
end
Expand All @@ -31,36 +32,50 @@ end
###############################################################################

policy "pol_utilization" do
validate $ds_snapshots_cost_mapping do
summary_template "AWS Account ID: {{with index data.result 0}}{{ .accountID }}{{end}} - {{ len data.result }} rows containing AWS old snapshot data"
detail_template <<-EOS
The following {{ len data.result }} old snapshots, for AWS Account: {{with index data.result 0}}{{ .accountID }}{{end}}, have exceeded the specified age of: 30 days old.

{{data.message}}
EOS
check eq(1, 0)
export "result" do
validate_each $ds_snapshots_cost_mapping do
summary_template "{{ with index data 0 }}{{ .policy_name }}{{ end }}: {{ len data }} AWS Old Snapshots Found"
check eq(val(item, "resourceID"), "")
hash_exclude "tags", "age", "savings", "savingsCurrency"
export do
resource_level true
field "accountID" do
label "Account ID"
end
field "accountName" do
label "Account Name"
end
field "region" do
label "Region"
field "resourceID" do
label "Resource ID"
end
field "resourceName" do
label "Resource Name"
end
field "tags" do
label "Resource Tags"
end
field "age" do
label "Days Old"
path "daysOld"
label "Age (Days)"
end
field "size" do
label "Size"
path "volumeSize"
label "Size (GB)"
end
field "resourceID" do
label "Resource ID"
path "snapshotId"
field "service" do
label "Service"
end
field "recommendationDetails" do
label "Recommendation"
end
field "parentType" do
label "Parent Resource Type"
end
field "parentId" do
label "Parent Resource ID"
end
field "snapshotType" do
label "Snapshot Type"
end
field "description" do
label "Description"
end
field "resourceName" do
label "Resource Name"
Expand All @@ -71,27 +86,24 @@ EOS
field "imageId" do
label "AMI"
end
field "dbClusterId" do
label "RDS DB Cluster ID"
end
field "dbInstanceId" do
label "RDS DB Instance ID"
field "region" do
label "Region"
end
field "savings" do
label "Estimated Monthly Savings"
end
field "savingsCurrency" do
label "Savings Currency"
end
field "tags" do
label "Tags"
field "resourceType" do
label "Resource Type"
end
field "lookbackPeriod" do
label "Snapshot Age Threshold (Days)"
end
field "id" do
label "ID"
path "snapshotId"
end
field "service" do
label "Service"
path "resourceID"
end
end
end
Expand Down
Loading

0 comments on commit 50c344d

Please sign in to comment.