# Infra Apply

> Run terraform plan for review and optionally apply infrastructure changes. Use when the user wants to preview or deploy infrastructure — always shows the plan before any apply.

- **Type:** Skill
- **Install:** `agentstack add skill-makigjuro-cloudstack-ai-plugins-infra-apply`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [makigjuro](https://agentstack.voostack.com/s/makigjuro)
- **Installs:** 0
- **Category:** [Cloud & Infrastructure](https://agentstack.voostack.com/c/cloud-infrastructure)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [makigjuro](https://github.com/makigjuro)
- **Source:** https://github.com/makigjuro/cloudstack-ai-plugins/tree/main/plugins/cloud-infra/skills/infra-apply
- **Website:** https://github.com/makigjuro/cloudstack-ai-plugins#quick-start

## Install

```sh
agentstack add skill-makigjuro-cloudstack-ai-plugins-infra-apply
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Infrastructure Apply

Generate a Terraform plan for review. Optionally apply after user confirmation.

## Arguments

- `{environment}` — Target environment (e.g., `dev`, `staging`, `prod`). Default: `dev`
- `{module}` — Specific module to plan (e.g., `aks-cluster`, `postgresql`). If omitted, plan all.
- `--apply` — Apply after showing the plan (requires explicit user confirmation)

## Configuration

Read `cloudstack.json` from the project root at the start of execution. Extract:
- `TF_PATH` = `infrastructure.terraformPath` (default: `infra/terraform/modules`)
- `TG_PATH` = `infrastructure.terragruntPath` (default: `infra/terragrunt`)
- `IAC_WRAPPER` = `infrastructure.iacWrapper` (default: `none`)

If `cloudstack.json` does not exist, auto-detect by scanning the project structure.

## Process

### Step 1: Validate First

Run `/infra-lint terraform` to ensure all modules are valid before planning.

### Step 2: Generate Plan

**If `IAC_WRAPPER` = `terragrunt`:**

Single module:
```bash
cd {TG_PATH}/{environment}/{module}
terragrunt plan -out=tfplan
```

All modules:
```bash
cd {TG_PATH}/{environment}
terragrunt run --all plan
```

**If `IAC_WRAPPER` = `none` (plain Terraform):**

Single module:
```bash
cd {TF_PATH}/{module}
terraform plan -var="environment={environment}" -out=tfplan
```

All modules — iterate over each module directory:
```bash
for dir in {TF_PATH}/*/; do
  echo "=== Planning $(basename $dir) ==="
  terraform -chdir="$dir" plan -var="environment={environment}" -out=tfplan
done
```

Note: With plain Terraform, you may need to pass additional `-var-file` or `-backend-config` flags depending on the project setup. Check for `{environment}.tfvars` files.

### Step 3: Review Plan Output

Display the plan summary:
- Resources to add
- Resources to change
- Resources to destroy

**CRITICAL:** If any resources will be **destroyed**, highlight this prominently and require explicit user confirmation before proceeding.

### Step 4: Apply (only if `--apply` and user confirms)

**If `IAC_WRAPPER` = `terragrunt`:**

Single module:
```bash
cd {TG_PATH}/{environment}/{module}
terragrunt apply tfplan
```

All modules:
```bash
cd {TG_PATH}/{environment}
terragrunt run --all apply
```

**If `IAC_WRAPPER` = `none`:**

Single module:
```bash
cd {TF_PATH}/{module}
terraform apply tfplan
```

All modules:
```bash
for dir in {TF_PATH}/*/; do
  terraform -chdir="$dir" apply tfplan
done
```

## Safety Rules

- NEVER apply to `prod` without showing the plan first and getting explicit user confirmation
- ALWAYS run plan before apply
- If the plan shows unexpected destroys, STOP and ask the user
- Clean up plan files after apply: `rm -f tfplan`
- For `--all` operations with Terragrunt, respect the dependency order defined in configs

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [makigjuro](https://github.com/makigjuro)
- **Source:** [makigjuro/cloudstack-ai-plugins](https://github.com/makigjuro/cloudstack-ai-plugins)
- **License:** MIT
- **Homepage:** https://github.com/makigjuro/cloudstack-ai-plugins#quick-start

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-makigjuro-cloudstack-ai-plugins-infra-apply
- Seller: https://agentstack.voostack.com/s/makigjuro
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
