hcl-processor 0.15.0rc0
A tool for analyzing HCL files.
Requires Python: <4.0,>=3.10

# 🚀 HCL Processor with AWS Bedrock

![MIT License](https://img.shields.io/badge/license-MIT-green)
![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue)
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)

⭐ Like this? Star the repo and help spread the word!

## ⚡ From Terraform to beautiful docs — powered by AI

AI (AWS Bedrock / Claude) automatically generates design and resource summaries by simply reading Terraform HCL files!

- ✅ Just write the code and get the documentation.
- ✅ Reduce man-hours for training and reviewing new staff.
- ✅ Instant understanding of complex IaC structures.

## Why this matters

- Writing Terraform is fast, but documenting it slows teams down.
- Missing docs = harder onboarding, harder reviews, more production risks.
- With HCL Processor, AI handles the grunt work — so you can focus on building.

## Project Summary

This is a Python tool that reads Terraform HCL files and sends them to the AWS Bedrock API (e.g. Claude) and generates
JSON output and Markdown reports.
It supports automated analysis and documentation of infrastructure configurations.

## Features and Functions at a Glance

> [!warning]
> The default region is us-east-1.
If you want to change it, please specify `bedrock.aws_region` in confg.yaml.

- ✅ Validate YAML configuration files with JSON Schema
- ✅ Reading and parsing HCL files and module files
- ✅ Bedrock API call and response parsing
- ✅ JSON output and Markdown report generation
- ✅ Per-file/per-folder batch processing support
- ✅ Failback design with chunk processing (retry)
- ✅ Log level adjustment (INFO/DEBUG)

## 🌟 Who will find this tool useful

- 🛠 You, the Terraform engineer tired of writing docs manually every day!
  - 👷‍♂️ SRE and infrastructure engineers who build and maintain Terraform HCL.
  - 👩‍💼 Managers and leaders needing to explain designs to new or non-technical staff.
  - 👨‍👩‍👧‍👦 Development teams looking to enrich PRs and review discussions with design intent.

## Install

```bash:bash
> hcl_processor --config_file config/config.yaml
```

## Usage Example
<!-- Example command-line usage, expected inputs, outputs, and options -->

### config yaml

```yaml:yaml

bedrock:
  # Note: The accuracy of the generated markdown can be improved by providing details of the content to be generated in system_prompt.
  system_prompt: |
    <instart prompt>
  output_json:
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "array",
      "items": { "type": "object" }
    }
  # Note: The following is the configuration for the Bedrock API.
  payload:
    anthropic_version: "bedrock-2023-05-31"  # API version of Anthropic (e.g. Claude) to be used. Specify specific version for bedrock integration.
    max_tokens: 4096                         # Maximum number of tokens generated by the model. Limit the length of the response.
    temperature: 0                           # Control the randomness of the output (0 is fully deterministic = most predictable response).
    top_p: 1                                 # Parameters for nucleus sampling. 1 is selected from the top 100% = no limit.
    top_k: 0                                 # Random selection from top k tokens (0 is disabled, i.e., all are eligible).

  read_timeout: 120
  connect_timeout: 30

  retries:
    max_attempts: 5
    mode: standard

input:
  # Note: Please describe the hcl file of terraform in which you want to generate the document.
  resource_data:
    files:
      - input/example.tf
  modules:
    # Note: Specify the modules (code in which the resource is described) of the resource for which you want to generate documentation.
    path: input/modules.tf
    enabled: true  # This allows you to switch between availability and unavailability.
  # Note: local.tf <env>(key):<directly>/file(value)
  local_files:
    - dev: input/dev.tf

output:
  # Note: You can specify the name of the intermediate file to generate the markdown.
  json_path: output/result.json
  # Note: You can specify the markdown_path name.
  markdown_path: output/result.md
  # Note: You can specify the format of markdown_template.
  # Note: support template title & table
  markdown_template: |
    ##### {title}

    {table}
  # Note: Specify the modules (code in which the resource is described) of the resource for which you want to generate documentation.
  failback:
    enabled: true  # This allows you to switch between availability and unavailability.
    # Note: For type, select modules or resource.
    type: modules
    # Note: The option can only be selected for the modules type.
    options:
      target: monitors # variable name

```

### UseCase

#### Create a monitor list from the terraform modules created and the call hcl

> [!warning]
> Failback is not supported when multiple modules calls are written in one file.
This feature will be supported in the next version, but implementing it will increase the generation cost.

Suppose we have the following hcl code

modules

```hcl:hcl
locals {
  platform_name    = var.platform_name
  platform_product = var.platform_product
}
resource "datadog_monitor" "monitors" {

  for_each = { for idx, mon in var.monitors : idx => mon }

  name    = each.value.name
  type    = each.value.type
  message = each.value.message
  query   = each.value.query

  tags = toset(concat([
    "platform_name:${local.platform_name}",
    "platform_product:${local.platform_product}"
  ], coalesce(each.value.tags, [])))

  monitor_thresholds {
    critical = try(each.value.thresholds.critical, null)
    warning  = try(each.value.thresholds.warning, null)
  }
}

```

resource

```hcl:hcl
locals {
  product_name = "apigateway"
}
module "apigateway_monitor" {
  source           = "../../modules/monitor/"
  platform_name    = local.platform_name
  platform_product = local.product_name
  monitors = [
    {
      name    = "[${local.env}] API Gateway Many Responses Rate"
      type    = "query alert"
      message = <<-EOT
      {{#is_alert}}
      ${local.slack_channel_mention}
      ${local.env == "prd" ? local.sre_pagerduty_mention : ""}
      The number of API Gateway responses has exceeded the critical threshold: ${local.apigateway_many_responses_rate_critical} req/sec.
      There is a possibility that requests will continue to increase.
      Please check the details, and if the API Gateway response count is rapidly increasing, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed.
      {{/is_alert}}
      {{#is_alert_recovery}}
      ${local.slack_channel_mention}
      The number of API Gateway responses has fallen below the critical threshold: ${local.apigateway_many_responses_rate_critical} req/sec.
      {{/is_alert_recovery}}
      {{#is_warning}}
      ${local.slack_channel_mention}
      The number of API Gateway responses has exceeded the warning threshold: ${local.apigateway_many_responses_rate_warning} req/sec.
      There is a possibility that requests will continue to increase.
      Please be aware that an alert may be triggered if this continues.
      {{/is_warning}}
      {{#is_warning_recovery}}
      ${local.slack_channel_mention}
      The number of API Gateway responses has fallen below the warning threshold: ${local.apigateway_many_responses_rate_warning} req/sec.
      {{/is_warning_recovery}}
      EOT
      query   = "sum(last_5m):default_zero(sum:aws.apigateway.count{env:${local.env}}.as_rate()) > ${local.apigateway_many_responses_rate_critical}"
      tags    = ["env:${local.env}", "team:${local.team_name}", "service:${local.project_prefix}"]
      thresholds = {
      critical = local.apigateway_many_responses_rate_critical
      warning  = local.apigateway_many_responses_rate_warning
      }
      description = "Monitors the number of API Gateway responses. If the response count increases rapidly, an alert will be triggered, providing an indicator to understand the service load status. Please consider appropriate actions if critical or warning thresholds are exceeded."
    },
    {
      name    = "[${local.env}] API Gateway 429 Error Count (Rate Limit)"
      type    = "log alert"
      message = <<-EOT
        {{#is_alert}}
        ${local.slack_channel_mention}
        ${local.env == "prd" ? local.sre_pagerduty_mention : ""}
        429 errors have been detected in API Gateway.
        Please check the details, and if the errors are due to hitting quotas, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed.
        {{/is_alert}}
      EOT
      query   = "logs(\"env:${local.env} service:${local.product_name} @http.status_code:429\").index(\"*\").rollup(\"count\").last(\"5m\") > ${local.apigateway_429_error_rate_critical}"
      tags    = ["env:${local.env}", "team:${local.team_name}", "service:${local.project_prefix}"]
      thresholds = {
        critical = local.apigateway_429_error_rate_critical
      }
      description = "Monitors API Gateway 429 errors, which indicate that the request rate has reached the rate limit. If the critical threshold is exceeded, an alert will be triggered, providing an indicator to understand service usage and, if necessary, request an increase in AWS rate limits."
    }
  ]
}
```

locals

```hcl:hcl
locals {
  env            = "dev"
  platform_name  = "aws"
  project_prefix = "aaa"
  team_name      = "xxx"
  role           = "sre"
  slack_channel         = join("_", [format("#%s", local.project_prefix), "alert", local.env])
  sre_pagerduty_mention = join("-", [format("@%s", local.project_prefix), local.role, "service", local.env])
  slack_channel_mention = join("_", [format("@slack-%s", local.project_prefix), "alert", local.env])
  # API Gateway Monitor Parameter
  apigateway_quartorly_limit              = 10000
  apigateway_many_responses_rate_critical = local.apigateway_quartorly_limit * 0.9
  apigateway_many_responses_rate_warning  = local.apigateway_quartorly_limit * 0.8
locals {
  env            = "dev"
  platform_name  = "aws"
  project_prefix = "aaa"
  team_name      = "xxx"
  role           = "sre"
  slack_channel         = join("_", [format("#%s", local.project_prefix), "alert", local.env])
  sre_pagerduty_mention = join("-", [format("@%s", local.project_prefix), local.role, "service", local.env])
  slack_channel_mention = join("_", [format("@slack-%s", local.project_prefix), "alert", local.env])
  # API Gateway Monitor Parameter
  apigateway_quartorly_limit              = 10000
  apigateway_many_responses_rate_critical = local.apigateway_quartorly_limit * 0.9
  apigateway_many_responses_rate_warning  = local.apigateway_quartorly_limit * 0.8
  apigateway_429_error_rate_critical = 60 # (Error Response Rate 1req/sec)
}
```

config/config.yaml

```yaml:yaml
bedrock:
  system_prompt: |
    The following Terraform code defines several calls to the Datadog Monitor module.
    Datadog Alert Design List (Title) Example

    ・ Please output an **Alert Design Document (json table format)** for each alert in the following format as described above.
    ・ The terraform code should be placed with reference to locals.tf.
    ・ The Alert Message column should be extracted from the terraform code and put the values as they are while expanding local. (e.g., message value) )
        sample)
          ```
          message = <<-EOT

          EOT
          ```
          Create the value while expanding local.tf for the contents of
    ・ Put the local variable as it is for the destination of the notification.
    ・ Put the local variable as it is for the destination of the Query.
    ・ Put the local variable as it is for the destination of the tag.
    ・ Put the local variable as it is for the destination of the alert message.
    ・ For threshold values, if the local variable is a numerical value, insert the value as is. If the local variable is a calculation formula, insert the calculation result and also include the formula itself in the format (calculation formula). Calculation formulas should be defined as local variables.
    ・ Monitor name prefix: [${local.env}] must never be included in the title.
    ・ Create columns for local dev, stg, and prd environments, respectively.
  output_json: |
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "array",
      "title": "Datadog Alert Design Schema",
      "description": "Schema for Datadog alert design document",
      "items": {
        "type": "object",
        "properties": {
          "Monitor Name": {"type": "string", "description": "The name of the monitor"},
          "Type": {"type": "string", "description": "The type of the monitor (e.g., query alert)"},
          "Query": {"type": "string", "description": "The query for the Datadog monitor"},
          "Evaluation Period": {"type": "string", "description": "The evaluation period (e.g., 5 minutes)"},
          "Notification Destination": {"type": "string", "description": "The notification destination (e.g., Slack channel)"},
          "Tags": {"type": "string", "description": "Tags associated with the monitor"},
          "Alert Message": {"type": "string", "description": "The message displayed when an alert is triggered"},
          "Remarks": {"type": "string", "description": "Remarks about the monitor"},
          "dev Threshold Condition": {"type": "string", "description": "Threshold condition for the development environment"}
        },
        "required": [
          "Monitor Name", "Type", "Query", "Evaluation Period", "Notification Destination", "Tags",
          "Alert Message", "Remarks", "dev Threshold Condition", "stg Threshold Condition", "prd Threshold Condition"
        ]
      }
    }
  payload:
    anthropic_version: "bedrock-2023-05-31"
    max_tokens: 4096
    temperature: 0
    top_p: 1
    top_k: 0
  read_timeout: 120
  connect_timeout: 30
  retries:
    max_attempts: 5
    mode: standard
schema_columns:
  - Monitor Name
  - Type
  - Query
  - Evaluation Period
  - Notification Destination
  - Tags
  - Alert Message
  - Remarks
  - dev Threshold Condition

output:
  json_path: output/output.json
  markdown_path: output/output.md
  markdown_template: |
    ###### {title}

    {table}
input:
  resource_data:
    files:
      - sample/test_data/monitor1/apigateway.tf
  local_files:
    - dev: sample/test_data/monitor1/dev/locals.tf
  modules:
    path: sample/test_data/modules/monitor/main.tf
    enabled: true
  failback:
    enabled: true
    type: modules
    options:
      target: monitors
```

command.

```bash:bash
❯ poetry run hcl-processor --config_file config/config.yaml
2025-07-26 12:38:22 [INFO] hcl_processor.main: Processing files...
2025-07-26 12:38:22 [INFO] hcl_processor.main: 1 files found to process.
2025-07-26 12:39:15 [INFO] hcl_processor.main: All files processed successfully.
```

##### Generated by

<!-- Write what is generated here-->

###### apigateway

| Monitor Name                             | Type        | Query                                                                                                                                                                  | Evaluation Period   | Notification Destination   | Tags                           | Alert Message                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Remarks                                                                                                                                                                                                                                                                            | dev Threshold Condition                                   |
|:-----------------------------------------|:------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------|:---------------------------|:-------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------|
| API Gateway Many Responses Rate          | query alert | sum(last_5m):default_zero(sum:aws.apigateway.count\{env:$\{local.env\}\}.as_rate()) > $\{local.apigateway_many_responses_rate_critical\}                               | 5 minutes           | #aaa_alert_dev             | env:dev, team:xxx, service:aaa | \{\{#is_alert\}\} <br> @slack-aaa_alert_dev <br>  <br> The number of API Gateway responses has exceeded the critical threshold: 9000 req/sec. <br> There is a possibility that requests will continue to increase. <br> Please check the details, and if the API Gateway response count is rapidly increasing, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed. <br> \{\{/is_alert\}\} <br> \{\{#is_alert_recovery\}\} <br> @slack-aaa_alert_dev <br> The number of API Gateway responses has fallen below the critical threshold: 9000 req/sec. <br> \{\{/is_alert_recovery\}\} <br> \{\{#is_warning\}\} <br> @slack-aaa_alert_dev <br> The number of API Gateway responses has exceeded the warning threshold: 8000 req/sec. <br> There is a possibility that requests will continue to increase. <br> Please be aware that an alert may be triggered if this continues. <br> \{\{/is_warning\}\} <br> \{\{#is_warning_recovery\}\} <br> @slack-aaa_alert_dev <br> The number of API Gateway responses has fallen below the warning threshold: 8000 req/sec. <br> \{\{/is_warning_recovery\}\} | Monitors the number of API Gateway responses. If the response count increases rapidly, an alert will be triggered, providing an indicator to understand the service load status. Please consider appropriate actions if critical or warning thresholds are exceeded.               | Critical: 9000 (10000 * 0.9), Warning: 8000 (10000 * 0.8) |
| API Gateway 429 Error Count (Rate Limit) | log alert   | logs("env:$\{local.env\} service:$\{local.product_name\} @http.status_code:429").index("*").rollup("count").last("5m") > $\{local.apigateway_429_error_rate_critical\} | 5 minutes           | #aaa_alert_dev             | env:dev, team:xxx, service:aaa | \{\{#is_alert\}\} <br> @slack-aaa_alert_dev <br>  <br> 429 errors have been detected in API Gateway. <br> Please check the details, and if the errors are due to hitting quotas, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed. <br> \{\{/is_alert\}\}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Monitors API Gateway 429 errors, which indicate that the request rate has reached the rate limit. If the critical threshold is exceeded, an alert will be triggered, providing an indicator to understand service usage and, if necessary, request an increase in AWS rate limits. | Critical: 60                                              |

#### Create a monitor list from the terraform resource created and the call hcl

Suppose we have the following hcl code

resource

```hcl:hcl
locals {
  product_name    = "apigateway"
  platform_name   = var.platform_name
  platform_product = var.platform_product
}

resource "datadog_monitor" "apigateway_many_responses_rate" {
  name    = "[${local.env}] API Gateway Many Responses Rate"
  type    = "query alert"
  message = <<-EOT
    {{#is_alert}}
    ${local.slack_channel_mention}
    ${local.env == "prd" ? local.sre_pagerduty_mention : ""}
    The number of API Gateway responses has exceeded the critical threshold: ${local.apigateway_many_responses_rate_critical} req/sec.
    There is a possibility that requests will continue to increase.
    Please check the details, and if the API Gateway response count is rapidly increasing, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed.
    {{/is_alert}}
    {{#is_alert_recovery}}
    ${local.slack_channel_mention}
    The number of API Gateway responses has fallen below the critical threshold: ${local.apigateway_many_responses_rate_critical} req/sec.
    {{/is_alert_recovery}}
    {{#is_warning}}
    ${local.slack_channel_mention}
    The number of API Gateway responses has exceeded the warning threshold: ${local.apigateway_many_responses_rate_warning} req/sec.
    There is a possibility that requests will continue to increase.
    Please be aware that an alert may be triggered if this continues.
    {{/is_warning}}
    {{#is_warning_recovery}}
    ${local.slack_channel_mention}
    The number of API Gateway responses has fallen below the warning threshold: ${local.apigateway_many_responses_rate_warning} req/sec.
    {{/is_warning_recovery}}
  EOT

  query = "sum(last_5m):default_zero(sum:aws.apigateway.count{env:${local.env}}.as_rate()) > ${local.apigateway_many_responses_rate_critical}"

  tags = toset([
    "platform_name:${local.platform_name}",
    "platform_product:${local.platform_product}",
    "env:${local.env}",
    "team:${local.team_name}",
    "service:${local.project_prefix}"
  ])

  monitor_thresholds {
    critical = local.apigateway_many_responses_rate_critical
    warning  = local.apigateway_many_responses_rate_warning
  }
}

resource "datadog_monitor" "apigateway_429_error_count" {
  name    = "[${local.env}] API Gateway 429 Error Count (Rate Limit)"
  type    = "log alert"
  message = <<-EOT
    {{#is_alert}}
    ${local.slack_channel_mention}
    ${local.env == "prd" ? local.sre_pagerduty_mention : ""}
    429 errors have been detected in API Gateway.
    Please check the details, and if the errors are due to hitting quotas, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed.
    {{/is_alert}}
  EOT

  query = "logs(\"env:${local.env} service:${local.product_name} @http.status_code:429\").index(\"*\").rollup(\"count\").last(\"5m\") > ${local.apigateway_429_error_rate_critical}"

  tags = toset([
    "platform_name:${local.platform_name}",
    "platform_product:${local.platform_product}",
    "env:${local.env}",
    "team:${local.team_name}",
    "service:${local.project_prefix}"
  ])

  monitor_thresholds {
    critical = local.apigateway_429_error_rate_critical
  }
}
```

locals

```hcl:hcl
locals {
  env            = "dev"
  platform_name  = "aws"
  project_prefix = "aaa"
  team_name      = "xxx"
  role           = "sre"
  slack_channel         = join("_", [format("#%s", local.project_prefix), "alert", local.env])
  sre_pagerduty_mention = join("-", [format("@%s", local.project_prefix), local.role, "service", local.env])
  slack_channel_mention = join("_", [format("@slack-%s", local.project_prefix), "alert", local.env])
  # API Gateway Monitor Parameter
  apigateway_quartorly_limit              = 10000
  apigateway_many_responses_rate_critical = local.apigateway_quartorly_limit * 0.9
  apigateway_many_responses_rate_warning  = local.apigateway_quartorly_limit * 0.8
locals {
  env            = "dev"
  platform_name  = "aws"
  project_prefix = "aaa"
  team_name      = "xxx"
  role           = "sre"
  slack_channel         = join("_", [format("#%s", local.project_prefix), "alert", local.env])
  sre_pagerduty_mention = join("-", [format("@%s", local.project_prefix), local.role, "service", local.env])
  slack_channel_mention = join("_", [format("@slack-%s", local.project_prefix), "alert", local.env])
  # API Gateway Monitor Parameter
  apigateway_quartorly_limit              = 10000
  apigateway_many_responses_rate_critical = local.apigateway_quartorly_limit * 0.9
  apigateway_many_responses_rate_warning  = local.apigateway_quartorly_limit * 0.8
  apigateway_429_error_rate_critical = 60 # (Error Response Rate 1req/sec)
}
```

config/config.yaml

```yaml:yaml
bedrock:
  system_prompt: |
    The following Terraform code defines several calls to the Datadog Monitor module.
    Datadog Alert Design List (Title) Example

    ・ Please output an **Alert Design Document (json table format)** for each alert in the following format as described above.
    ・ The terraform code should be placed with reference to locals.tf.
    ・ The Alert Message column should be extracted from the terraform code and put the values as they are while expanding local. (e.g., message value) )
        sample)
          ```
          message = <<-EOT

          EOT
          ```
          Create the value while expanding local.tf for the contents of
    ・ Put the local variable as it is for the destination of the notification.
    ・ Put the local variable as it is for the destination of the Query.
    ・ Put the local variable as it is for the destination of the tag.
    ・ Put the local variable as it is for the destination of the alert message.
    ・ For threshold values, if the local variable is a numerical value, insert the value as is. If the local variable is a calculation formula, insert the calculation result and also include the formula itself in the format (calculation formula). Calculation formulas should be defined as local variables.
    ・ Monitor name prefix: [${local.env}] must never be included in the title.
    ・ Create columns for local dev, stg, and prd environments, respectively.
  output_json: |
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "array",
      "title": "Datadog Alert Design Schema",
      "description": "Schema for Datadog alert design document",
      "items": {
        "type": "object",
        "properties": {
          "Monitor Name": {"type": "string", "description": "The name of the monitor"},
          "Type": {"type": "string", "description": "The type of the monitor (e.g., query alert)"},
          "Query": {"type": "string", "description": "The query for the Datadog monitor"},
          "Evaluation Period": {"type": "string", "description": "The evaluation period (e.g., 5 minutes)"},
          "Notification Destination": {"type": "string", "description": "The notification destination (e.g., Slack channel)"},
          "Tags": {"type": "string", "description": "Tags associated with the monitor"},
          "Alert Message": {"type": "string", "description": "The message displayed when an alert is triggered"},
          "Remarks": {"type": "string", "description": "Remarks about the monitor"},
          "dev Threshold Condition": {"type": "string", "description": "Threshold condition for the development environment"}
        },
        "required": [
          "Monitor Name", "Type", "Query", "Evaluation Period", "Notification Destination", "Tags",
          "Alert Message", "Remarks", "dev Threshold Condition", "stg Threshold Condition", "prd Threshold Condition"
        ]
      }
    }
  payload:
    anthropic_version: "bedrock-2023-05-31"
    max_tokens: 4096
    temperature: 0
    top_p: 1
    top_k: 0
  read_timeout: 120
  connect_timeout: 30
  retries:
    max_attempts: 5
    mode: standard
schema_columns:
  - Monitor Name
  - Type
  - Query
  - Evaluation Period
  - Notification Destination
  - Tags
  - Alert Message
  - Remarks
  - dev Threshold Condition

output:
  json_path: output/output.json
  markdown_path: output/output.md
  markdown_template: |
    ###### {title}

    {table}
input:
  resource_data:
    files:
      - sample/test_data/monitor1/apigateway.tf
  local_files:
    - dev: sample/test_data/monitor1/dev/locals.tf
  modules:
    enabled: false
  failback:
    enabled: true
    type: resource
```

command.

```bash:bash
> hcl_processor --config_file config/config.yaml
2025-05-07 18:30:42 INFO: Processing files...
2025-05-07 18:30:42 INFO: 1 files found to process.
2025-05-07 18:30:42 INFO: Processing sample/test_data/monitor1/apigateway.tf
2025-05-07 18:30:42 INFO: No AWS profile specified, using environment variables for credentials.
2025-05-07 18:30:42 INFO: Using AWS region: ap-northeast-1
2025-05-07 18:30:57 INFO: Successfully processed file: sample/test_data/monitor1/apigateway.tf
<<mask>>: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
  df = df.applymap(clean_cell)                                                                                              2025-05-07 18:30:57 INFO: Saved to Markdown file: output/output.md
2025-05-07 18:30:57 INFO: Deleting JSON file: output/output.json
2025-05-07 18:30:57 INFO: All files processed successfully.
```

###### apigateway

| Monitor Name                             | Type        | Query                                                                                               | Evaluation Period   | Notification Destination   | Tags                                                                                            | Alert Message                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Remarks                                         | dev Threshold Condition                                       |
|:-----------------------------------------|:------------|:----------------------------------------------------------------------------------------------------|:--------------------|:---------------------------|:------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------|:--------------------------------------------------------------|
| API Gateway Many Responses Rate          | query alert | sum(last_5m):default_zero(sum:aws.apigateway.count\{env:dev\}.as_rate()) > 9000                     | 5 minutes           | #aaa_alert_dev             | platform_name:aws, platform_product:$\{local.platform_product\}, env:dev, team:xxx, service:aaa | \{\{#is_alert\}\} <br> @slack-aaa_alert_dev <br>  <br> The number of API Gateway responses has exceeded the critical threshold: 9000 req/sec. <br> There is a possibility that requests will continue to increase. <br> Please check the details, and if the API Gateway response count is rapidly increasing, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed. <br> \{\{/is_alert\}\} <br> \{\{#is_alert_recovery\}\} <br> @slack-aaa_alert_dev <br> The number of API Gateway responses has fallen below the critical threshold: 9000 req/sec. <br> \{\{/is_alert_recovery\}\} <br> \{\{#is_warning\}\} <br> @slack-aaa_alert_dev <br> The number of API Gateway responses has exceeded the warning threshold: 8000 req/sec. <br> There is a possibility that requests will continue to increase. <br> Please be aware that an alert may be triggered if this continues. <br> \{\{/is_warning\}\} <br> \{\{#is_warning_recovery\}\} <br> @slack-aaa_alert_dev <br> The number of API Gateway responses has fallen below the warning threshold: 8000 req/sec. <br> \{\{/is_warning_recovery\}\} | Monitors the rate of API Gateway responses      | Critical: > 9000 (10000 * 0.9), Warning: > 8000 (10000 * 0.8) |
| API Gateway 429 Error Count (Rate Limit) | log alert   | logs("env:dev service:apigateway @http.status_code:429").index("*").rollup("count").last("5m") > 60 | 5 minutes           | #aaa_alert_dev             | platform_name:aws, platform_product:$\{local.platform_product\}, env:dev, team:xxx, service:aaa | \{\{#is_alert\}\} <br> @slack-aaa_alert_dev <br>  <br> 429 errors have been detected in API Gateway. <br> Please check the details, and if the errors are due to hitting quotas, consider submitting a request to AWS via the Service Quotas console to raise the rate limits as needed. <br> \{\{/is_alert\}\}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Monitors the count of 429 errors in API Gateway | Critical: > 60                                                |




## Config Schema
<!-- Detailed explanation of the YAML configuration structure, required fields, and schema rules -->

The configuration file (`config.yaml`) must follow the structure below.

### Top-level keys (required)

- `bedrock`: AWS Bedrock API configuration.
- `input`: Information about the Terraform files or folders to process.
- `output`: Paths for saving the JSON and Markdown outputs.
- `schema_columns` (optional but recommended): Array of column names for the Markdown table.

---

### `bedrock` (object, required)

| Field            | Type      | Required | Description                                                            |
|------------------|-----------|----------|------------------------------------------------------------------------|
| aws_profile      | string    | ❌       | AWS profile to use for authentication. default aws profile env                                |
| aws_region           | string    | ❌       | AWS region where Bedrock is deployed. default us-east-1                                 |
| system_prompt    | string    | ✅       | System-level prompt to prepend to the Bedrock request.                |
| payload          | object    | ✅       | API parameters for the Bedrock model.                                 |
| └ anthropic_version | string | ✅       | Anthropic API version.                                                |
| └ max_tokens     | integer   | ✅       | Maximum tokens in the response.                                       |
| └ temperature    | number    | ✅       | Sampling temperature for randomness.                                  |
| └ top_p          | number    | ✅       | Top-p sampling parameter.                                             |
| └ top_k          | number    | ✅       | Top-k sampling parameter.                                             |
| read_timeout     | integer   | ❌       | Optional timeout for read operations.                                 |
| connect_timeout  | integer   | ❌       | Optional timeout for connection.                                      |
| retries          | object    | ❌       | Retry configuration (e.g., max_attempts, mode).                       |
| output_json      | object    | ✅       | JSON schema describing the expected API response format