Skip to content

Portal | Level: L0: Entry | Topics: VS Code | Domain: DevOps & Tooling

VS Code for DevOps - Primer

Why VS Code for DevOps

VS Code has become the dominant editor for DevOps work because of its extension ecosystem, integrated terminal, and remote development capabilities. It handles Python, Terraform, YAML, Docker, and shell scripts equally well - the exact mix a DevOps engineer lives in daily.

Essential Extensions

Infrastructure as Code

Extension What It Does
HashiCorp Terraform Syntax highlighting, autocomplete, go-to-definition, terraform fmt on save
Ansible (Red Hat) Playbook syntax, linting via ansible-lint, module autocomplete
YAML (Red Hat) Schema validation for K8s manifests, Helm values, GitHub Actions
Helm Intellisense Autocomplete for Helm template values and built-in objects

Containers and Kubernetes

Extension What It Does
Docker (Microsoft) Dockerfile syntax, image management, container logs, compose support
Kubernetes (Microsoft) Cluster explorer, manifest intellisense, apply/delete from editor

Python and General Development

Extension What It Does
Python (Microsoft) IntelliSense, debugging, linting, testing integration
Ruff Fast Python linter/formatter (replaces flake8 + black + isort)
Pylance Type checking, auto-imports, advanced IntelliSense
GitLens Git blame inline, file history, branch comparison

Remote Development

Extension What It Does
Remote - SSH Edit files on remote servers as if local
Dev Containers Develop inside Docker containers with full tooling
Remote - Tunnels Connect to remote machines via tunnel (no SSH config needed)
WSL Seamless Linux development from Windows

AI Assistants

Extension What It Does
GitHub Copilot AI code completion, inline suggestions
GitHub Copilot Chat Conversational AI in the editor sidebar
Continue Open-source AI assistant, supports multiple models
Cline Autonomous AI coding agent in VS Code

Core Configuration

settings.json (User Settings)

{
  // Editor basics
  "editor.tabSize": 2,
  "editor.formatOnSave": true,
  "editor.rulers": [100],
  "editor.renderWhitespace": "boundary",
  "editor.bracketPairColorization.enabled": true,

  // Terminal
  "terminal.integrated.defaultProfile.linux": "bash",
  "terminal.integrated.scrollback": 10000,

  // Files
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true,
  "files.associations": {
    "*.tf": "terraform",
    "*.tfvars": "terraform",
    "*.j2": "jinja",
    "Jenkinsfile": "groovy",
    "Dockerfile.*": "dockerfile"
  },

  // Python (with ruff)
  "[python]": {
    "editor.defaultFormatter": "charliermarsh.ruff",
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.fixAll.ruff": "explicit",
      "source.organizeImports.ruff": "explicit"
    },
    "editor.tabSize": 4
  },

  // Terraform
  "[terraform]": {
    "editor.defaultFormatter": "hashicorp.terraform",
    "editor.formatOnSave": true
  },

  // YAML with K8s and GH Actions schema validation
  "[yaml]": {
    "editor.defaultFormatter": "redhat.vscode-yaml",
    "editor.tabSize": 2
  },
  "yaml.schemas": {
    "kubernetes": ["k8s/**/*.yaml", "manifests/**/*.yaml"],
    "https://json.schemastore.org/github-workflow.json": ".github/workflows/*.yml"
  },

  // Git
  "git.autofetch": true,
  "git.enableSmartCommit": true,
  "gitlens.currentLine.enabled": true
}

Workspace Settings (.vscode/settings.json)

Project-specific config that lives in the repo:

{
  "python.testing.pytestEnabled": true,
  "python.testing.pytestArgs": ["tests/", "--tb=short", "-q"],

  "files.exclude": {
    "**/__pycache__": true,
    "**/.pytest_cache": true,
    ".ruff_cache": true,
    ".terraform": true,
    "*.tfstate*": true
  },

  "terraform.modulePaths": ["devops/terraform/modules"]
}

Integrated Terminal

The terminal is where most DevOps work happens within VS Code.

  • Split terminals (Ctrl+Shift+5): Run kubectl logs -f in one pane, edit in another
  • Multiple terminals: Keep separate terminals for different contexts (app, infra, monitoring)
  • Terminal profiles: Set up named profiles for different environments:
"terminal.integrated.profiles.linux": {
  "staging": {
    "path": "bash",
    "args": ["-c", "export KUBECONFIG=~/.kube/staging; exec bash"],
    "icon": "server"
  },
  "production": {
    "path": "bash",
    "args": ["-c", "export KUBECONFIG=~/.kube/production; exec bash"],
    "icon": "warning",
    "color": "terminal.ansiRed"
  }
}

Tasks (tasks.json)

Automate common commands:

// .vscode/tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Lint",
      "type": "shell",
      "command": "ruff check . && ruff format --check .",
      "group": "test"
    },
    {
      "label": "Test",
      "type": "shell",
      "command": "pytest --cov=app --cov-fail-under=70 --tb=short -q",
      "group": { "kind": "test", "isDefault": true }
    },
    {
      "label": "Helm Lint",
      "type": "shell",
      "command": "helm lint devops/helm/grokdevops -f devops/helm/values-dev.yaml"
    },
    {
      "label": "Docker Build",
      "type": "shell",
      "command": "docker build -t grokdevops:test ."
    }
  ]
}

Run with Ctrl+Shift+P → "Tasks: Run Task".

Debugging (launch.json)

Debug FastAPI directly in VS Code:

// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "FastAPI",
      "type": "debugpy",
      "request": "launch",
      "module": "uvicorn",
      "args": ["app.api.main:app", "--reload", "--port", "8000"],
      "console": "integratedTerminal"
    },
    {
      "name": "Pytest",
      "type": "debugpy",
      "request": "launch",
      "module": "pytest",
      "args": ["tests/", "-v", "--tb=long"],
      "console": "integratedTerminal"
    }
  ]
}

Set breakpoints by clicking the gutter, hit F5 to debug with full variable inspection.

Remote Development

Remote-SSH

Connect to remote servers and edit files as if local: 1. Install Remote-SSH extension 2. Ctrl+Shift+P → "Remote-SSH: Connect to Host" 3. Enter user@hostname (uses your ~/.ssh/config) 4. Open folders, use terminal, debug - all on the remote machine

Dev Containers

Define your dev environment as code:

// .devcontainer/devcontainer.json
{
  "name": "grokdevops",
  "image": "mcr.microsoft.com/devcontainers/python:3.11",
  "features": {
    "ghcr.io/devcontainers/features/docker-in-docker:2": {},
    "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
      "helm": "3.14", "minikube": "none"
    },
    "ghcr.io/devcontainers/features/terraform:1": { "version": "1.5.7" }
  },
  "customizations": {
    "vscode": {
      "extensions": [
        "charliermarsh.ruff",
        "ms-python.python",
        "hashicorp.terraform",
        "ms-azuretools.vscode-docker",
        "redhat.vscode-yaml"
      ]
    }
  },
  "postCreateCommand": "pip install -r requirements.txt"
}

Guarantees every contributor has identical tools, versions, and extensions.

Multi-Root Workspaces

When working across app + infra + config repos:

// devops.code-workspace
{
  "folders": [
    { "path": ".", "name": "grokdevops (app)" },
    { "path": "../infrastructure", "name": "infrastructure (terraform)" },
    { "path": "../k8s-config", "name": "k8s-config (manifests)" }
  ]
}

Open with code devops.code-workspace.

Working With DevOps File Types

Terraform

  • Format on save via HashiCorp extension
  • F12 on module reference jumps to source
  • Autocomplete for resource properties and built-in functions
  • Outline view shows all resources, variables, outputs

Helm Charts

  • YAML extension validates against K8s schemas
  • Helm Intellisense autocompletes .Values.xxx
  • Use terminal for helm template to see rendered output

Dockerfiles

  • Syntax highlighting for stages, instructions, shell commands
  • Right-click → "Build Image"
  • Linting for common issues (latest tag, etc.)

Shell Scripts

  • ShellCheck extension: Lints bash/sh for common errors
  • Bash Debug extension: Step-through debugging
  • Select lines → send to terminal to test snippets

VS Code + Claude Code

Claude Code runs in VS Code's integrated terminal naturally: 1. Open VS Code's terminal 2. Run claude 3. Claude Code reads/edits the same files visible in the editor 4. Changes appear in real-time in VS Code 5. Use VS Code's source control panel to review changes

Best of both: VS Code for navigation and review, Claude Code for execution.


Wiki Navigation

  • VS Code Flashcards (CLI) (flashcard_deck, L1) — VS Code