Skip to content

RedHatQE/interop-aws-reporter

Repository files navigation

interop-aws-reporter

A reporting tool project based on the RedHatQE/cloudwash cli.

This tool creates a Slack message report (with an attached HTML file), containing the data of OCP resources left in a given AWS account.

Reporting is done directly to a configured Slack channel using SlackAPI or a Slack Webhook url.

Content

Slack channel configuration

Once the reporting Slack channel has been set up, an activation must be done using either a webhook url, or a SlackAPI application bot.

For both methods, you need to create an app for the reporting tool, such as my-project-cw-reporter.

Using a post request with a webhook url

  • Create a new app using: https://api.slack.com/apps

  • Generate a new webhook url for the reporting channel, by following this tutorial: https://api.slack.com/messaging/webhooks

  • Once activated, make sure you're able to send messages like this:

    curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' <your-slack-webhook-url>

Using a SlackAPI application bot

Local usage

Setup VirtualEnv

Use poetry to manage virtualenv.

pip install poetry

Execute

To run locally you can export the following environment variables:

poetry install

export CLEANUP_AWS__AUTH__ACCESS_KEY=<aws-access-key>  # AWS access key ID
export CLEANUP_AWS__AUTH__SECRET_KEY=<aws-secret-key>  # AWS secret key
export CLEANUP_AWS__AUTH__REGIONS='["all"]'   # Optional; set the list of regions for reporting
export CLEANUP_AWS__CRITERIA__OCPS__OCP_CLIENT_REGION=<For more info check out: https://github.com/RedHatQE/cloudwash/blob/master/README.md>
export CLEANUP_AWS__CRITERIA__OCPS__SLA=3d  # Optional; set the reporting SLA time for filtering resources

export CHANNEL_ID=<slack-channel-id>
export SLACK_BOT_TOKEN=<slack-bot-token>

poetry run python3 interop_aws_reporter/app.py

Using in Openshift-Ci

The interop-aws-reporter tool is a containerized project which can be easily integrated into the openshift/release repo.

Running periodic job for reporting on a daily/weekly/monthly/yearly basis in OpenShift CI is very simple, you can do one of the following:

  • Set the following secrets in your job's credentials files that required by the tool:
    • slack-webhook-url
    • aws-access-key
    • aws-secret-key
    • channel-id
    • slack-bot-token
  • Create a config file for running the job using a cron value.
  • Add the mpiit-interop-aws-reporter-ref ref as the test step in your config

For adding optional variables to the job's, check out the cloudwash docs.

Additional env variables for the tool can be set in the job's config file.

About

This project builds an app that triggers a Slack reports of cloud usage based on the RedHatQE/cloudwash cli.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors