Token导航 LogoToken导航TokenDH.com
Terraform Ingest Example logo
开发工具stdio官方级别未说明来源级核验

Terraform Ingest Example

MCP Server

一个用于管理和集成Terraform模块的工具,支持从GitHub导入模块、自动生成文档和代码示例,适用于Terraform项目迁移和开发效率提升。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
开发工具Shell命令行工具

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

zloeber

提供方

zloeber

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uvx terraform-ingest --version

详细介绍

地形摄取示例

这是一个vscode的完整工作区示例,用于大型自定义地形模块集合,该集合来自一个我非常尊重的地形专业团队, Cloudposse。他们已经为社区生产了近200个专业质量的AWS地形模块以及更多。以下是如何通过地形摄取和MCP摄取他们的所有模块,作为进一步地形工作的基础。

安装

需要一些工具才能使其正常工作。您可以通过以下方式安装它们 布置 可以使用附带的为您的用户帐户安装 ./configure.sh 脚本。

注: 我建议你仔细阅读安装脚本,以了解你在做什么。我还强烈建议在用户shell中配置mise,以便在包含mise.toml配置文件的文件夹中自动激活。否则,你可以跑 mise en 以按需启用它。

对于这个例子,您还需要地形摄取工具。在本次练习中,我特意将其排除在自动化软件包安装之外。您可以使用uv作为工具来安装它:

uv tool install terraform-ingest
uvx terraform-ingest --version
备注 要升级运行 uv tool upgrade terraform-ingest

为了充分利用此MCP服务器,它应该与HashiCorp的terraform MCP服务器配对,甚至可能与云文档MCP配对(在这种情况下,AWS是所有这些模块的目标)。看看包括 vscode的MCP文件.

设置

我们可以使用terraform摄取直接导入目标github组织。因为Cloudposse非常擅长标准化模块和标记版本,所以我们有目的地只针对最新的标记版本和 ./src 路径。以下操作是在提交此项目之前完成的,不需要再次运行即可继续使用此示例项目:

uv tool run terraform-ingest init ./.vscode/cloudposse.yaml
uv tool run terraform-ingest import github --org cloudposse-terraform-components --token '' --terraform-only --base-path './src' --max-tags 1 --replace -c ./.vscode/cloudposse.yaml
备注 排除 --token 如果您的环境中已经有此参数,请将其设置为 GITHUB_TOKEN

由于模块太多,我发现最好在启动mcp服务器之前将它们全部摄取。使用以下命令可以轻松完成此操作:

uv tool run terraform-ingest ingest --auto-install-deps .vscode/cloudposse.yaml

重要 如果不包括--auto-install-deps,则MCP服务器可能无法正常运行,具体取决于您的配置。第一次运行此步骤时要有耐心,因为库非常大。

这需要一两分钟的时间,并以摄入模块的摘要结束。

...
Ingestion complete!
Processed 167 module(s)
Summaries saved to output

Vector Database Statistics:
  Collection: terraform_modules
  Documents: 167
  Strategy: chromadb-default

示例1-迁移

一个虚构的在线应用程序,出售天堂门票。

最初为使用本地AWS地形的AWS虚拟低成本订购系统生成了一堆地形。然后,在摄取地形摄取配置并启动MCP服务器以从清单创建转换文档以尽可能多地使用CloudPosse模块后,我提示Copilot使用地形摄取。已找到此文件 这里.

Create a document of possible terraform modules to use for the terraform code in ./terraform. Use search_modules_vector to find as many relevant modules as possible for this folder. If applicable modules are found, use get_module_details to get information needed to create the terraform module blocks need to use them. Ensure you create code for the modules that use the ssh git url format and repository ref as the version. Create a CONVERSION.md of the modules you would create and how you would convert the project.

你可以看到结果 这里 在那里,它正确地找到了可以使用的适用模块,并给出了分阶段迁移到这些模块的方法。

示例2-按需文档

此MCP服务器最简单的用例可能是无需离开编辑器即可轻松访问您的模块需求。

由于几十个模块分布在存储库中,当您编写新的或现有的Terraform时,回忆每个模块的输入/输出可能会很痛苦。为了解决这个问题,您可以使用地形摄取作为快速获取这些细节并生成示例模块块来使用它们的一种手段。

# Generate example module call for one of your custom modules
Generate an example terraform module call for aws-kms using the source format for ssh git

# Get expected inputs for one of your modules
What are the expected inputs for the aws-argocd-github-repo terraform module?

使用副驾驶中的最后一个提示,它将使用search_modules工具获取模块信息,在表中提供所有必需和可选的输入,并提供示例用法。漂亮!

示例2-输出

这是在代理聊天窗口中启动MCP服务器的情况下运行的,没有可供参考的文件,模块上的输出很好

What are the expected inputs for the aws-argocd-github-repo terraform module?

让我搜索aws-argocd-github repo模块以获取其预期的输入。

search_modules 已完成输入:{ “query”:“aws argocd github仓库” }

根据搜索结果,以下是 aws argocd github repo Terraform模块的预期输入 (v2.2.0版本):

所需输入

变量类型描述
regionstringAWS区域
descriptionstring存储库的描述
gitignore_entrieslist(string).gitignore条目列表(例如。, [".idea/", ".vscode/"])
github_base_urlstringGitHub基础API端点(企业级必需)
github_codeowner_teamslist(string)CODEOWNERS文件的团队列表(例如。, ["@ACME/cloud-admins"])
github_userstringGitHub用户名
github_user_emailstringGitHub用户电子邮件
github_organizationstringGitHub组织名称
github_token_overridestringGitHub API令牌(可以改用SSM)

可选输入

变量类型默认值描述
environments列表(对象)[]ArgoCD应用程序设置和部署密钥的环境
permissions列表(对象)[]团队访问的存储库权限对象
create_repo bool的。 true是创建存储库还是使用现有存储库
deploy_keys_enabled bool的。 true启用ArgoCD同步的GitHub部署密钥
required_pull_request_reviews bool的。 true执行PR审查限制
push_restrictions_enabled bool的。 true对主要分支机构实施推送限制
vulnerability_alerts_enabled bool的。 false启用安全警报
web_commit_signoff_required bool的。 false要求提交签字
manifest_kubernetes_namespace字符串"argocd"ArgoCD的Kubernetes命名空间
ssm_github_api_key字符串"/argocd/github/api_key"指向GitHub API密钥的SSM路径
ssm_github_deploy_key_format字符串"/argocd/deploy_keys/%s"部署密钥的SSM路径格式
slack_notifications_channel字符串""用于通知的Slack频道
use_local_github_credentials bool的。 false使用环境变量而不是SSM

示例用法

module "argocd_github_repo" {
  source = "git::ssh://git@github.com/cloudposse-terraform-components/aws-argocd-github-repo.git//src?ref=v2.2.0"

  region                  = "us-east-1"
  description             = "ArgoCD desired state repository"
  github_user             = "ci-acme"
  github_user_email       = "ci@acme.com"
  github_organization     = "ACME"
  github_base_url         = "https://github.com/"
  github_codeowner_teams  = ["@ACME/cloud-admins", "@ACME/cloud-posse"]
  gitignore_entries       = [".idea/", ".vscode/", "*.tfvars"]
  
  permissions = [
    {
      team_slug  = "admins"
      permission = "admin"
    },
    {
      team_slug  = "engineering"
      permission = "push"
    }
  ]

  environments = [
    {
      tenant      = "mgmt"
      environment = "uw2"
      stage       = "sandbox"
      auto-sync   = true
    }
  ]

  deploy_keys_enabled            = true
  required_pull_request_reviews  = true
  push_restrictions_enabled      = true
  vulnerability_alerts_enabled   = false
}

示例3-直接模块插入

使用内联副目录,您可以查找并直接插入示例模块调用。以下是一个AWS KMS密钥的示例 ./示例/项目2 使用此内联聊天提示:

Find the best terraform module using terraform-ingest to deploy an ec2 auto-scale group into AWS running Amazon linux and create module blocks that use them via git ssh target format and the latest tagged release.

目录标签

目录标签

开发工具Shell命令行工具本地部署Terraform模块管理AWS自动化

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotoken部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP