==================
**terraform_rums**
==================

Overview
--------

A Python module to call the Terraform Cloud API and retrieve data for Resources Under Management (RUMs).  

> **CAUTION!** This may take a while to run if the Organization has a large number of Workspaces.

Usage
-----

Installation:

.. code-block:: BASH

   pip3 install terraform_rums
   # or
   python3 -m pip install terraform_rums

Bash:

.. code-block:: BASH

   tfc_rums -o <organization> -t <token> -f <filename> -u <api_url> -p <page_size> -d <delay>

Python:

.. code-block:: PYTHON

   import terraform_rums as tfr
   quota = tfr.get_subscription_rums(
      <organization>,
      <token>,
      <api_url>
   )
   rums = tfu.get_workspace_data(
      <organization>,
      <token>,
      <api_url>,
      <page_size>,
      <delay>,
      quota
   )

Execution example:

.. code-block:: BASH

   tfc_rums -o myorg -t mytoken -f myfile.csv

   Terraform RUM Statistics
   -------
   Run parameters:
   Organization: myorg
   Filename: myfile.csv
   API URL: https://app.terraform.io/api/v2
   Page size: 50
   Delay: 1.0
   -------
   Reading Workspace: aws-myworkspace-dev...
   Reading Workspace: aws-myworkspace-prod...
   Reading Workspace: aws-myworkspace-test...
   -------
   Workspaces: 3
   Quota: 500
   RUMs: 10
   Billable RUMs: 10
   Delta: 490
   Usage percentage: 2.00%
   -------
   Writing data to myfile.csv...
    
Output in CSV file example:

.. code-block:: TXT

   workspace_id,workspace_name,rum_count,billable_rum_count
   aws-myworkspace-dev,2,2
   aws-myworkspace-prod,5,5
   aws-myworkspace-test,3,3

Arguments
---------

- organization - Terraform Cloud Organization name. Required.
- token - Terraform Cloud API token. Required.
- filename - CSV filename to save the output data to. Default is "report.csv".
- api_url - Terraform Cloud API URL. Default is "https://app.terraform.io/api/v2".
- page_size - Number of items per page. Default is 50.
- delay - Delay (in seconds) between API calls. Default is 0.0.

API Documentation
-----------------

https://developer.hashicorp.com/terraform/cloud-docs/api-docs
