Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/offgriddev/tf-metrics-action

An experimental GitHub Action intended to gather static metrics on terraform use in a codebase
https://github.com/offgriddev/tf-metrics-action

Last synced: about 1 month ago
JSON representation

An experimental GitHub Action intended to gather static metrics on terraform use in a codebase

Awesome Lists containing this project

README

        

# Terraform Metric Collector (TMC)

TMC is a GitHub Action that performs static analysis on Terraform Code to do a simple count of several datapoints provided through the library [@evops/hcl-terraform-parser](https://www.npmjs.com/package/@evops/hcl-terraform-parser). This parser provides the engine for analysis, and this action allows for aggregation of these through snapshots in CI that allow you to analyze your team's development through time.

## How to Use

```yml
- name: Generate Code Metrics for Commit
id: metrics
uses: offgriddev/tf-metrics-action@main
with:
github_token: ${{ github.token }}
event: ${{ toJson(github.event) }}
```

This action has one export: `export_filename`. This stores the filename for the report generated by the complexity reporter.

The action will produce a report that looks like this:

```json
{
"actor": "offgriddev",
"sha": "b8824d770a1ba20c41329ab92bead39ec85f25ed",
"ref": "refs/heads/main",
"repository": {
"owner": "offgriddev",
"repo": "tf-metrics-action"
},
"files": [
{
"file": "./terraform/main.tf",
"report": {
"path": 9,
"variables": 0,
"outputs": 0,
"required_providers": 0,
"managed_resources": 2,
"data_resources": 0,
"module_calls": 0
}
},
{
"file": "./terraform/providers.tf",
"report": {
"path": 9,
"variables": 0,
"outputs": 0,
"required_providers": 1,
"provider_configs": 1,
"managed_resources": 0,
"data_resources": 0,
"module_calls": 0
}
},
{
"file": "./terraform/variables.tf",
"report": {
"path": 9,
"variables": 1,
"outputs": 0,
"required_providers": 0,
"managed_resources": 0,
"data_resources": 0,
"module_calls": 0
}
}
],
"dateUtc": "2023-11-08T23:30:03.837Z"
}
```