AgentSkillsCN

tfdc-policy-search

使用 tfdc 在 Terraform 模块注册表中进行策略集搜索。适用于需要通过关键词查找 Sentinel 或 OPA 策略集、发现 CIS 基准或合规策略,或获取策略 ID 以配合 tfdc 策略获取功能时使用。

SKILL.md
--- frontmatter
name: tfdc-policy-search
description: Search Terraform policy sets using tfdc. Use when you need to find Sentinel or OPA policy sets by keyword, discover CIS benchmarks or compliance policies, or get policy IDs for use with tfdc policy get.

tfdc policy search

Search Terraform policy sets.

Usage

bash
tfdc policy search -query <keyword> [-format text]

Flags

FlagRequiredDefaultDescription
-queryYesSearch query (e.g., cis, aws, networking)
-formatNotextOutput format: text, json, markdown

Output fields

FieldDescription
terraform_policy_idPolicy ID in policies/namespace/name/version format
namePolicy set name
titlePolicy set title
downloadsDownload count

Examples

bash
# Search for CIS policies
tfdc policy search -query cis

# Search with JSON output
tfdc policy search -query aws -format json

JSON output

json
{
  "items": [
    {
      "terraform_policy_id": "policies/hashicorp/CIS-Policy-Set-for-AWS-Terraform/1.0.1",
      "name": "CIS-Policy-Set-for-AWS-Terraform",
      "title": "Pre-written Sentinel Policies for AWS CIS Foundations Benchmarking",
      "downloads": 647442
    }
  ],
  "total": 1
}

Workflow

Use with tfdc policy get to fetch full policy details:

bash
# Search
tfdc policy search -query cis -format json | jq '.items[].terraform_policy_id'

# Get details
tfdc policy get -id policies/hashicorp/CIS-Policy-Set-for-AWS-Terraform/1.0.1