terraform_usage


Nameterraform_usage JSON
Version 2.1.8 PyPI version JSON
download
home_pagehttps://gitlab.com/fer1035_python/modules/pypi-terraform_usage
SummaryGet Terraform Workspace and Run usage statistics.
upload_time2024-01-29 12:00:41
maintainer
docs_urlNone
authorAhmad Ferdaus Abd Razak
requires_python>=3.9,<4.0
licenseGPL-2.0-only
keywords terraform cloud usage statistics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===================
**terraform_usage**
===================

Overview
--------

A Python module to call the Terraform Cloud API and retrieve data for total and applied Runs of Workspaces.

Usage
-----

Installation:

.. code-block:: BASH

   pip3 install terraform_usage
   # or
   python3 -m pip install terraform_usage

Usage instructions are in the script built-in help document. Run the following to see options and default parameters.

Bash:

.. code-block:: BASH

   python </oath/to>/terraform_usage -h

Python:

.. code-block:: PYTHON

   import terraform_usage as tfu
   help(tfu)

Execution example:

.. code-block:: BASH

   python </path/to>/terraform_usage -o abdahmad -t $TFE_TOKEN -k "*abdahmad-*" -m advanced -f abdahmad.csv -s 2023-11-01 -e 2023-11-30

   Run parameters:
   Organization: abdahmad
   Keyword: *abdahmad-*
   Filename: abdahmad.csv
   Start date: 2023-11-01
   End date: 2023-11-30
   Mode: advanced
   API URL: https://app.terraform.io/api/v2
   Page size: 50
   Delay: 1.0
   -------
   Getting page 1 of Workspaces.
   Found 3 Workspaces.
   Getting Run data for Workspace ids-aws-abdahmad-dev.
   Getting page 1 of Runs.
   Getting Run data for Workspace ids-aws-abdahmad-prod.
   Getting page 1 of Runs.
   Getting Run data for Workspace ids-aws-abdahmad-test.
   Getting page 1 of Runs.
   Creating CSV file abdahmad.csv.
   Writing data to abdahmad.csv.
    
Output in CSV file example:

.. code-block:: TXT

   workspace,all_runs,successful_applies,total_time
   abdahmad-dev,4,0,53
   abdahmad-prod,0,0,0
   abdahmad-test,0,0,0

Execution Modes
---------------

- basic
    - Function
        - Get total number of Runs and successful Applies for all time.
    - Available filters
        - Workspace name pattern
    - Pros and cons
        - Faster execution
        - Less details

- advanced
    - Function
        - Get total number of Runs, successful Applies, and total Run time.
    - Available filters
        - Workspace name pattern
        - Start date
        - End date
    - Pros and cons
        - Potentially slower execution for a large number of Workspaces and Runs.
        - More details

Error Handling
--------------

- Error: Skipping run due to missing attribute(s).
    - A Run is missing a timestamp for a status. Normally caused by Runs stuck in Pending state, which should be discarded if they aren't meant to complete, successfully or otherwise.
- Error: One or more Python exceptions.
    - Multiple possible causes. One of the most common is due to the script hitting the Terraform Cloud API rate limit (30 requests per second). There is a safeguard that slows down execution to avoid this.

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

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/fer1035_python/modules/pypi-terraform_usage",
    "name": "terraform_usage",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "Terraform,Cloud,usage,statistics",
    "author": "Ahmad Ferdaus Abd Razak",
    "author_email": "fer1035@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3d/63/f6bd38f158edf2978e40e89e3fd28971c68c4f65c837032e4da48ae0c9a3/terraform_usage-2.1.8.tar.gz",
    "platform": null,
    "description": "===================\n**terraform_usage**\n===================\n\nOverview\n--------\n\nA Python module to call the Terraform Cloud API and retrieve data for total and applied Runs of Workspaces.\n\nUsage\n-----\n\nInstallation:\n\n.. code-block:: BASH\n\n   pip3 install terraform_usage\n   # or\n   python3 -m pip install terraform_usage\n\nUsage instructions are in the script built-in help document. Run the following to see options and default parameters.\n\nBash:\n\n.. code-block:: BASH\n\n   python </oath/to>/terraform_usage -h\n\nPython:\n\n.. code-block:: PYTHON\n\n   import terraform_usage as tfu\n   help(tfu)\n\nExecution example:\n\n.. code-block:: BASH\n\n   python </path/to>/terraform_usage -o abdahmad -t $TFE_TOKEN -k \"*abdahmad-*\" -m advanced -f abdahmad.csv -s 2023-11-01 -e 2023-11-30\n\n   Run parameters:\n   Organization: abdahmad\n   Keyword: *abdahmad-*\n   Filename: abdahmad.csv\n   Start date: 2023-11-01\n   End date: 2023-11-30\n   Mode: advanced\n   API URL: https://app.terraform.io/api/v2\n   Page size: 50\n   Delay: 1.0\n   -------\n   Getting page 1 of Workspaces.\n   Found 3 Workspaces.\n   Getting Run data for Workspace ids-aws-abdahmad-dev.\n   Getting page 1 of Runs.\n   Getting Run data for Workspace ids-aws-abdahmad-prod.\n   Getting page 1 of Runs.\n   Getting Run data for Workspace ids-aws-abdahmad-test.\n   Getting page 1 of Runs.\n   Creating CSV file abdahmad.csv.\n   Writing data to abdahmad.csv.\n    \nOutput in CSV file example:\n\n.. code-block:: TXT\n\n   workspace,all_runs,successful_applies,total_time\n   abdahmad-dev,4,0,53\n   abdahmad-prod,0,0,0\n   abdahmad-test,0,0,0\n\nExecution Modes\n---------------\n\n- basic\n    - Function\n        - Get total number of Runs and successful Applies for all time.\n    - Available filters\n        - Workspace name pattern\n    - Pros and cons\n        - Faster execution\n        - Less details\n\n- advanced\n    - Function\n        - Get total number of Runs, successful Applies, and total Run time.\n    - Available filters\n        - Workspace name pattern\n        - Start date\n        - End date\n    - Pros and cons\n        - Potentially slower execution for a large number of Workspaces and Runs.\n        - More details\n\nError Handling\n--------------\n\n- Error: Skipping run due to missing attribute(s).\n    - A Run is missing a timestamp for a status. Normally caused by Runs stuck in Pending state, which should be discarded if they aren't meant to complete, successfully or otherwise.\n- Error: One or more Python exceptions.\n    - Multiple possible causes. One of the most common is due to the script hitting the Terraform Cloud API rate limit (30 requests per second). There is a safeguard that slows down execution to avoid this.\n\nAPI Documentation\n-----------------\n\nhttps://developer.hashicorp.com/terraform/cloud-docs/api-docs\n",
    "bugtrack_url": null,
    "license": "GPL-2.0-only",
    "summary": "Get Terraform Workspace and Run usage statistics.",
    "version": "2.1.8",
    "project_urls": {
        "Homepage": "https://gitlab.com/fer1035_python/modules/pypi-terraform_usage",
        "Repository": "https://gitlab.com/fer1035_python/modules/pypi-terraform_usage"
    },
    "split_keywords": [
        "terraform",
        "cloud",
        "usage",
        "statistics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b833ca7f3a470ed9471de761895cc7523a44aa8fd3a3344427b3a89f1f5c3d9",
                "md5": "2f14f2081b87c52d0de8666a92e1df9b",
                "sha256": "52d2e2ae8b1195d54006414508f63668dc4ad00cc4217828895d32f5098f1654"
            },
            "downloads": -1,
            "filename": "terraform_usage-2.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2f14f2081b87c52d0de8666a92e1df9b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 7706,
            "upload_time": "2024-01-29T12:00:40",
            "upload_time_iso_8601": "2024-01-29T12:00:40.047468Z",
            "url": "https://files.pythonhosted.org/packages/6b/83/3ca7f3a470ed9471de761895cc7523a44aa8fd3a3344427b3a89f1f5c3d9/terraform_usage-2.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d63f6bd38f158edf2978e40e89e3fd28971c68c4f65c837032e4da48ae0c9a3",
                "md5": "5b187f73609369dcc4fc509ff50df729",
                "sha256": "a59c7bf87b299fba1e1a824b2804feea3faaf9caec71373d4617aed8dcff5039"
            },
            "downloads": -1,
            "filename": "terraform_usage-2.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "5b187f73609369dcc4fc509ff50df729",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 6104,
            "upload_time": "2024-01-29T12:00:41",
            "upload_time_iso_8601": "2024-01-29T12:00:41.668714Z",
            "url": "https://files.pythonhosted.org/packages/3d/63/f6bd38f158edf2978e40e89e3fd28971c68c4f65c837032e4da48ae0c9a3/terraform_usage-2.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-29 12:00:41",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "fer1035_python",
    "gitlab_project": "modules",
    "lcname": "terraform_usage"
}
        
Elapsed time: 0.35164s