<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Terraform on Chen Kai Blog</title><link>https://www.chenk.top/zh/categories/terraform/</link><description>Recent content in Terraform on Chen Kai Blog</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Thu, 26 Mar 2026 09:00:00 +0000</lastBuildDate><atom:link href="https://www.chenk.top/zh/categories/terraform/index.xml" rel="self" type="application/rss+xml"/><item><title>Terraform 实战（八）：一条命令拉起全栈</title><link>https://www.chenk.top/zh/terraform-agents/08-end-to-end-walkthrough/</link><pubDate>Thu, 26 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/08-end-to-end-walkthrough/</guid><description>&lt;p>本系列第 2 至第 7 篇所构建的全部模块，最终在此完成整合。只需运行一次 &lt;code>terraform apply&lt;/code>，你就能在阿里云上部署一套完整、可观测、带预算控制的 Agent 运行时栈——包含约 31 个资源，实际耗时约 7 分钟，生产环境规模下全包成本约为 ¥12,530/月。&lt;/p></description></item><item><title>Terraform 实战（七）：可观测与成本告警</title><link>https://www.chenk.top/zh/terraform-agents/07-observability-and-cost-control/</link><pubDate>Tue, 24 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/07-observability-and-cost-control/</guid><description>&lt;p>Agent 具备非确定性、多步骤执行特性，并频繁调用高成本 API。这三者叠加意味着：若未在上线首日完成可观测性埋点，故障发生后将极难定位与调试。本文通过 Terraform 打通日志、链路追踪和指标三条管线，全部汇聚至统一仪表盘，并配套六个可直接用于排查真实故障的 SLS 查询，以及四个已在生产环境中成功拦截事故的钉钉告警。&lt;/p></description></item><item><title>Terraform 实战（六）：LLM Gateway 与密钥管理</title><link>https://www.chenk.top/zh/terraform-agents/06-llm-gateway-and-secrets/</link><pubDate>Sun, 22 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/06-llm-gateway-and-secrets/</guid><description>&lt;p>我在许多尚未成熟的 Agent 架构中反复看到一个通病：每个 Agent 都在自己的 &lt;code>.env&lt;/code> 文件里存一份 &lt;code>OPENAI_API_KEY&lt;/code>。有时是同一个 key，有时各不相同，甚至还有同事在原型阶段留下的个人密钥。等到账单来了，没人说得清哪个 Agent 消耗了多少 token；而一旦密钥泄露（这几乎是必然的），你就得像打地鼠一样，在十几个 &lt;code>.env&lt;/code> 文件里来回折腾。&lt;/p></description></item><item><title>Terraform 实战（五）：向量库、RDS 与对象存储</title><link>https://www.chenk.top/zh/terraform-agents/05-storage-for-agent-memory/</link><pubDate>Fri, 20 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/05-storage-for-agent-memory/</guid><description>&lt;p>大多数教程在讲解 Agent 记忆时都一笔带过，简单说一句“把 embeddings 放 Pinecone，会话存 Postgres，截图扔 S3”就完事。但在阿里云上，这三类存储其实都有对应的托管服务。能否用 Terraform 正确配置它们，直接决定了你的记忆系统是稳定运行，还是某天凌晨 4 点因磁盘爆满而丢失整整三周的对话历史。&lt;/p></description></item><item><title>Terraform 实战（四）：ECS、ACK 还是函数计算</title><link>https://www.chenk.top/zh/terraform-agents/04-compute-for-agent-runtime/</link><pubDate>Wed, 18 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/04-compute-for-agent-runtime/</guid><description>&lt;p>在设计 Agent 系统架构时，最关键的是确定 Agent 循环进程的运行位置。阿里云提供了三种主流方案及一个常被忽略的 ECI 方案。虽然选错方案不会导致系统崩溃（后续仍可迁移），但可能会多花几周时间搭建基础设施，并且每月浪费数千元算力。&lt;/p></description></item><item><title>Terraform 实战（三）：复用 VPC 与安全基线</title><link>https://www.chenk.top/zh/terraform-agents/03-vpc-and-security-baseline/</link><pubDate>Mon, 16 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/03-vpc-and-security-baseline/</guid><description>&lt;p>今天要写的是我 Agent 项目里被复制次数最多的 Terraform 代码：一个 &lt;code>vpc-baseline&lt;/code> 模块。它为后续所有组件（ECS、RDS、OpenSearch、ACK）提供了统一、可复用的网络基础。总共约 200 行 HCL，建议亲手编写一遍，方便后续复用和定制。&lt;/p></description></item><item><title>Terraform 实战（二）：Provider 认证与 State</title><link>https://www.chenk.top/zh/terraform-agents/02-provider-and-state-setup/</link><pubDate>Sat, 14 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/02-provider-and-state-setup/</guid><description>&lt;p>读到这里，关掉页面，打开终端吧。等你回来时，应该已经准备好以下内容：&lt;/p>
&lt;ol>
&lt;li>安装好且版本锁定的 &lt;code>alicloud&lt;/code> Terraform Provider。&lt;/li>
&lt;li>配置妥当的认证方式——用的是正确的方法，而非图省事的做法。&lt;/li>
&lt;li>基于 OSS Bucket 和 Tablestore 锁定的远程状态存储。&lt;/li>
&lt;li>三个工作空间（&lt;code>dev&lt;/code>、&lt;code>staging&lt;/code>、&lt;code>prod&lt;/code>），共用后端但状态相互隔离。&lt;/li>
&lt;li>能跑通的 &lt;code>terraform plan&lt;/code>，哪怕配置文件还是空的。&lt;/li>
&lt;/ol>
&lt;p>至此，Agent 尚未部署——本阶段仅搭建基础设施底座，后续所有文章都以此为基础。如果跳过此步骤，等到第三篇文章再临时补救，一周内遭遇 tfstate 损坏的概率极高。&lt;/p></description></item><item><title>Terraform 实战（一）：为何 IaC 是唯一出路</title><link>https://www.chenk.top/zh/terraform-agents/01-why-terraform-for-agents/</link><pubDate>Thu, 12 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/zh/terraform-agents/01-why-terraform-for-agents/</guid><description>&lt;p>过去十八个月，我在阿里云上交付了四个 Agent 系统。其中三个起步都是某人在控制台点出来的单台 ECS 上的 &lt;code>tmux&lt;/code> 会话。这三个项目，通常在第二位工程师加入、生产环境资源告急，或安全团队索要网络拓扑图时，迫使我不得不在某个手忙脚乱的周末紧急重构。&lt;/p></description></item></channel></rss>