惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
K
Kaspersky official blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Security Latest
Security Latest
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Simon Willison's Weblog
Simon Willison's Weblog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
O
OpenAI News
Help Net Security
Help Net Security
N
News and Events Feed by Topic
博客园 - 司徒正美
U
Unit 42
Security Archives - TechRepublic
Security Archives - TechRepublic
The Cloudflare Blog
D
DataBreaches.Net
Y
Y Combinator Blog
AI
AI
L
LINUX DO - 最新话题
C
CXSECURITY Database RSS Feed - CXSecurity.com
H
Heimdal Security Blog
宝玉的分享
宝玉的分享
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
TaoSecurity Blog
TaoSecurity Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Project Zero
Project Zero
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
V
V2EX
博客园 - 【当耐特】
S
SegmentFault 最新的问题
小众软件
小众软件
L
LangChain Blog
N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
T
Tor Project blog
AWS News Blog
AWS News Blog
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
S
Securelist
T
Troy Hunt's Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Visualize Terraform, Kubernetes, and Pulumi from the Terminal with npx infrasketch
Raghvendra P · 2026-05-14 · via DEV Community

TL;DR: Run npx infrasketch . in any IaC repository to instantly open an interactive architecture diagram in your browser. No login, no install, no file upload. Works with Terraform, Kubernetes, Pulumi, CloudFormation, CDK, Bicep, Terragrunt, and Docker Compose.

The copy-paste problem with IaC diagrams

You finish a Terraform module, open Lucidchart or draw.io, manually drag in an EC2 box, an RDS cylinder, an ALB arrow — 45 minutes recreating what the code already describes. Two weeks later the code changes, the diagram doesn't, and you've got a lie pinned to your Confluence page. I've seen this on every team I've worked with.

The browser-based InfraSketch tool at infrasketch.cloud cuts most of that: paste your HCL, YAML, or JSON and get an interactive diagram instantly, no account required. But there was still friction. You had to leave your terminal, copy the file contents, navigate to a website. For anyone living in the command line, that adds up over a day.

The CLI removes that last step. Point it at a file, a directory, or a raw GitHub URL, and it generates the diagram and opens your browser — usually in under two seconds. In CI where there's no browser to open, --no-open prints the shareable URL to stdout so you can pipe it wherever you need it.

What npx infrasketch does (and what it doesn't)

The CLI is a thin Node.js wrapper published to npm as infrasketch. When you run it, it reads your IaC file or directory, serializes the content into a base64-encoded JSON fragment, appends that fragment to the InfraSketch web app URL, and opens the result in your default browser.

What it doesn't do matters more than you'd expect:

  • Your code never leaves your machine — no upload, no server processing.
  • No account, no API key, nothing to sign up for.
  • It doesn't touch your IaC files. Read-only.
  • No background process. It runs, opens the browser, and exits.

The diagram is rendered entirely in the browser using the URL fragment. Browsers don't send the hash to the server — they only transmit the path and query string. So when you open https://infrasketch.cloud/#eJy..., the server gets a plain GET / with no idea what's in the fragment. That's not a hack; it's just how HTTP works, and we're leaning into it deliberately. It also means the tool works in air-gapped environments as long as the browser can load the InfraSketch page.

Zero-install usage: your first diagram in 10 seconds

Because the CLI is on npm, you can run it immediately with npx without installing anything globally. Navigate to any directory that contains IaC files and run:

npx infrasketch .

Enter fullscreen mode Exit fullscreen mode

That's it. The CLI will scan the current directory, detect the format automatically, and open your browser. If you have a mixed repository with, say, a terraform/ subdirectory and a k8s/ subdirectory, run it from the root — it will pick the dominant format or let you point it at a subdirectory.

If you prefer a permanent global install to skip the npx overhead on every invocation, add it to your PATH once:

npm install -g infrasketch

Enter fullscreen mode Exit fullscreen mode

After that, infrasketch . works from any directory, just like terraform or kubectl.

Single file mode

When you want to diagram a specific file rather than an entire directory, pass the file path directly:

npx infrasketch main.tf

Enter fullscreen mode Exit fullscreen mode

Single file mode is useful when you're working on a large module and want to check just the resources you're currently editing. The CLI reads only that file, so it's faster for large repositories where a full directory scan would pull in many files you don't care about right now.

The format is auto-detected from the file extension and content. .tf files are parsed as Terraform HCL, .yaml and .yml files trigger heuristic detection to distinguish between Kubernetes manifests, Docker Compose files, and CloudFormation templates. For ambiguous cases you can override with the --type flag:

npx infrasketch template.yaml --type cloudformation

Enter fullscreen mode Exit fullscreen mode

Supported values for --type are: terraform, kubernetes, pulumi, cloudformation, cdk, bicep, terragrunt, docker-compose.

Directory scan mode — multi-file Terraform projects

Real Terraform projects rarely live in a single file. A production module typically spans main.tf, variables.tf, outputs.tf, locals.tf, and any number of resource-specific files. Directory scan mode reads all of them and stitches them into one diagram:

npx infrasketch ./terraform/environments/prod/

Enter fullscreen mode Exit fullscreen mode

The CLI recursively finds all .tf files under the given path, concatenates their contents, and feeds the combined HCL to the diagram renderer. This gives you a complete picture of the environment rather than a partial view of whichever file you happened to open first.

For Terragrunt projects where each module lives in its own subdirectory with a terragrunt.hcl, point the CLI at the root of the deployment tree:

npx infrasketch ./live/prod/ --type terragrunt

Enter fullscreen mode Exit fullscreen mode

It will discover all terragrunt.hcl files and combine the dependency graph across modules, giving you visibility into how modules reference each other — something that's notoriously hard to visualize manually.

Tip: For very large Terraform codebases (hundreds of files), consider running the CLI against a specific module subdirectory rather than the repository root. The URL fragment has a practical size limit around 2 MB of raw content, which covers most real-world modules comfortably.

Kubernetes and Pulumi projects

Kubernetes works the same way. Point it at a directory of YAML files and it picks up Deployments, Services, Ingresses, ConfigMaps, StatefulSets, DaemonSets — and renders how they connect:

npx infrasketch ./k8s/ --type kubernetes

Enter fullscreen mode Exit fullscreen mode

The --type flag is optional here if your YAML files have the standard apiVersion and kind fields — the auto-detector recognizes Kubernetes manifests reliably. But if you have a directory that mixes Kubernetes YAML with other YAML (for example, a Helm chart with both templates and values files), being explicit avoids ambiguity.

For more detail on the Kubernetes diagram format and what relationships are visualized, see the Kubernetes diagram generator guide.

Pulumi projects work similarly. Navigate to a Pulumi project directory (the one containing Pulumi.yaml) and run:

npx infrasketch . --type pulumi

Enter fullscreen mode Exit fullscreen mode

The CLI reads the Pulumi program source — TypeScript, Python, Go, or YAML — and extracts resource declarations. Because Pulumi programs are general-purpose code rather than declarative config, the extraction is necessarily heuristic: it looks for new aws.ec2.Instance()-style patterns in TypeScript/Python and equivalent patterns in other languages. Coverage is good for standard resource declarations but may miss resources created inside complex loops or conditional logic.

Remote GitHub raw URL mode

You don't have to clone a repository to diagram it. Pass any raw GitHub URL (or any other URL that returns plain text) and the CLI will fetch it, parse it, and open the diagram:

npx infrasketch https://raw.githubusercontent.com/hashicorp/terraform-provider-aws/main/examples/two-tier/main.tf

Enter fullscreen mode Exit fullscreen mode

This mode is particularly useful for:

  • Reviewing open-source Terraform modules before adding them as dependencies
  • Quickly understanding the architecture of a reference implementation you found
  • Sharing a diagram of a public repository without cloning it locally
  • Generating diagrams in documentation pipelines where the source lives in a separate repo

The URL is fetched by the CLI process on your machine (not by the browser or any server), parsed locally, and then encoded into the diagram URL. Your network request goes to GitHub's raw content CDN, not to InfraSketch servers.

CI/CD pipeline integration (--no-open flag)

In a headless CI environment there's no browser to open, so the default behavior would hang or error. The --no-open flag suppresses browser launch and instead prints the diagram URL to stdout:

npx infrasketch main.tf --no-open

Enter fullscreen mode Exit fullscreen mode

This emits a single line like:

https://infrasketch.cloud/#eJyVVdtu2zgQ...

Enter fullscreen mode Exit fullscreen mode

You can capture this URL and use it anywhere: a PR comment, a Slack notification, a build artifact, a release note. Here's a complete GitHub Actions workflow that posts the diagram URL as a PR comment whenever Terraform files change:

name: Terraform Diagram

on:
pull_request:
paths:
- '**.tf'
- '**.tfvars'

jobs:
diagram:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Generate diagram URL
id: diagram
run: |
URL=$(npx infrasketch . --no-open)
echo "url=$URL" >> "$GITHUB_OUTPUT"

- name: Post diagram comment
uses: actions/github-script@v7
with:
script: |
const url = '${{ steps.diagram.outputs.url }}';
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## Architecture Diagram\n\n[View interactive diagram](${url})\n\n> Generated by InfraSketch CLI`
});

Enter fullscreen mode Exit fullscreen mode

If you'd rather use the purpose-built GitHub Action instead of the raw CLI in CI, see the GitHub Action guide — it handles the comment posting and diff detection automatically with less boilerplate.

How it works under the hood (URL encoding, no upload, privacy)

If you're going to run a tool against production Terraform code, you should know what it actually does. Here's the full flow:

  1. Reads file contents from disk (or fetches from URL). No preprocessing — the raw content goes through as-is, including variable references and module calls.
  2. Wraps the content in a JSON envelope: {"type":"terraform","code":"..."}. Multi-file mode concatenates everything into the code field with separator comments between files.
  3. Gzip-compresses the JSON and base64-encodes the result into a compact ASCII string.
  4. Appends the encoded string to the InfraSketch URL as a hash fragment: https://infrasketch.cloud/#.
  5. Opens that URL in your default browser (open on macOS, xdg-open on Linux, start on Windows). The web app decodes the fragment entirely client-side.

The key detail is step 5. The URL fragment — everything after the # — is never transmitted in HTTP requests. When your browser loads https://infrasketch.cloud/#eJy..., the actual HTTP request to the server is just GET /. No server ever sees your infrastructure code. That's a browser standard, not something we're doing specially — we're just building on top of it.

This also means the diagram URL is a permanent, shareable link with no expiry. The entire diagram state is encoded in the URL itself — there's no server-side session or storage. You can bookmark it, share it in Slack, or save it in documentation and it will work forever, as long as the InfraSketch web app is running.

Combining CLI with GitHub Action for full automation

The CLI is for you while you're coding. The GitHub Action is for your reviewers when they're not.

Practically, the workflow goes: you write a new Terraform module for a VPC peering connection, run npx infrasketch . locally to make sure the diagram looks right (subnets, route tables, peering connections all there), then open a PR. The GitHub Action (pandey-raghvendra/infrasketch@v4) fires automatically and posts the diagram as a comment. Reviewers click the link, see the architecture interactively, no tooling required on their end.

The CLI is fast and zero-ceremony — just a command. The Action is automated and requires no one to remember to run anything. They cover different moments in the same workflow, not the same moment twice.

Comparison table: CLI vs browser vs GitHub Action vs MCP

Method Best for Install needed Works in CI Opens browser
Browser Quick one-off diagrams, paste-and-view None No Already in browser
CLI (npx infrasketch) Local dev, scripting, remote URLs Node.js (npx auto-installs) Yes (--no-open) Yes (default)
GitHub Action Automated PR comments on IaC changes None (uses Action) Yes (built for it) No
MCP Server AI-assisted coding in Claude Code / Cursor Node.js (npx auto-installs) No Yes (via AI prompt)

FAQ

Does npx infrasketch work without internet access?

First run via npx needs to download the package, so yes, internet required there. After that, npm install -g infrasketch once and it runs offline. The generated URL needs a browser to load the InfraSketch web app — so some internet to load the page initially, though your IaC code never gets uploaded to any server regardless.

What happens with .tfvars files that contain secrets?

The code goes into the URL fragment, which is never sent to a server. But the fragment does show up in browser history and in any URL you share. So treat the URL like you'd treat the source code — don't paste it in a public Slack channel if the file has real credentials in it. Stick to main.tf or module directories for diagramming; leave the .tfvars with the actual secrets out of it.

Can I use the CLI with Terraform workspaces?

Yes, workspaces only affect state — the HCL source files are the same regardless of which workspace you're on. npx infrasketch . works normally. If you have workspace-specific variable files like prod.tfvars, you can point the CLI at them directly.

How large can the IaC file be before the URL gets too long?

HCL compresses well — gzip typically gets 5-10x reduction before base64, so a 500 KB Terraform project ends up under 100 KB in the URL. In practice, URL length limits never bite you with normal module-sized codebases. If you're running against an entire monorepo root with hundreds of files, run it against a subdirectory instead.

Can I get the diagram URL without opening the browser, even locally?

--no-open works anywhere, not just CI. npx infrasketch main.tf --no-open on your laptop prints the URL to stdout without touching the browser. Pipe it to pbcopy, drop it in a script, whatever you need.

Diagram your infrastructure in 10 seconds Run npx infrasketch . in your IaC repo right now — or try the browser tool directly with no install required. Try InfraSketch Free →