# Terraform CLI Setup

Terraform CLI 安装与初始化技能。当用户本地未安装 Terraform 时自动完成安装，确保 terraform 命令可用并能执行...

- Repository: https://github.com/agentscope-ai/QwenPaw (37135 stars)
- Category: DevOps
- License: Apache-2.0
- Last updated: 2026-10-30
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add agentscope-ai/QwenPaw --skill terraform-cli-setup -g -a claude-code -y`
Codex: `npx skills add agentscope-ai/QwenPaw --skill terraform-cli-setup -g -a codex -y`
Cursor: `npx skills add agentscope-ai/QwenPaw --skill terraform-cli-setup -g -a cursor -y`
Gemini CLI: `npx skills add agentscope-ai/QwenPaw --skill terraform-cli-setup -g -a gemini-cli -y`

## Description

Terraform CLI 安装与初始化技能。当用户本地未安装 Terraform 时自动完成安装，确保 terraform 命令可用并能执行 init/validate。不负责 Provider 凭证配置，凭证在实际使用时由 terraform-skill 引导。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

Category: setup

# Terraform CLI 安装与初始化

## 目标

- 检测本地是否已安装 `terraform`，未安装则自动安装
- 确保 `terraform version` 正常输出
- 引导完成 `terraform init` 初始化工作区
- 处理 Provider 下载、镜像配置等基础环境问题

> **关于 Provider 凭证配置**：各云厂商的凭证配置（AWS/Azure/GCP/阿里云等）不在本技能范围内。Provider 凭证在实际使用 Terraform 时按需配置，请参考 **terraform-skill** 中的 Provider 凭证配置引导。

## 何时触发此技能

- 用户首次使用 Terraform 相关功能
- 执行 `terraform` 命令报错 `command not found`
- `terraform init` 报 Provider 下载失败（网络/镜像问题）
- 用户主动要求安装或重新安装 Terraform
- 其他 Terraform 技能（terraform-skill）的前置依赖检查

## 完整流程

### 第 1 步：检测安装状态

```bash
which terraform 2>/dev/null || echo "NOT_INSTALLED"
```

如果未安装，进入安装流程。如果已安装，跳到第 3 步。

### 第 2 步：安装 Terraform

#### macOS (Homebrew, 推荐)

```bash
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
```

#### macOS (手动下载)

```bash
ARCH=$(uname -m)
case "$ARCH" in
    x86_64|amd64) ARCH="amd64" ;;
    arm64|aarch64) ARCH="arm64" ;;
esac
curl -fsSL "https://releases.hashicorp.com/terraform/1.14.6/terraform_1.14.6_darwin_${ARCH}.zip" -o /tmp/terraform.zip
mkdir -p ~/.local/bin
unzip -o /tmp/terraform.zip -d ~/.local/bin/
chmod +x ~/.local/bin/terraform
export PATH="$HOME/.local/bin:$PATH"
```

#### Linux (手动下载)

```bash
ARCH=$(uname -m)
case "$ARCH" in
    x86_64|amd64) ARCH="amd64" ;;
    arm64|aarch64) ARCH="arm64" ;;
esac
curl -fsSL "https://releases.hashicorp.com/terraform/1.14.6/terraform_1.14.6_linux_${ARCH}.zip" -o /tmp/terraform.zip
mkdir -p ~/.local/bin
unzip -o /tmp/terraform.zip -d ~/.local/bin/
chmod +x ~/.local/bin/terraform
export PATH="$HOME/.local/bin:$PATH"
```

#### Linux (APT, Debian/Ubuntu)

The rest: https://github.com/agentscope-ai/QwenPaw/blob/HEAD/plugins/bundle/cloudpaw/skills/terraform-cli-setup/SKILL.md
