Skip to main content
⏳ Estimated read time: 3 min read

Stackgen Extension for Visual Studio Code

Overview

The StackGen Extension for Visual Studio Code brings the power of StackGen’s Terraform module creation and management directly into Visual Studio Code, enabling you to create, edit, and publish infrastructure modules more efficiently. This extension is designed to work seamlessly with StackGen’s Open in IDE feature, so you can transition smoothly between the StackGen web UI and your local development environment.

Features

  • Module Explorer: Browse, open, and modify all your StackGen Terraform modules directly from VS Code.
  • Direct Sync: Any changes you save are automatically synced back to StackGen.

Get Started with the StackGen Extension

Follow these steps to set up and start using the extension:

Prerequisites

Click to view

Install the Stackgen Extension

Click to view
  1. From the Visual Studio Code Marketplace, search for StackGen.

  2. Click Install.

  3. Configure Your Personal Access Token (PAT) in the StackGen Web UI. By default, once you install the StackGen extension, it will ask you to provide the PAT.

  4. Copy and paste the PAT and hit Return.

    Enter PAT

  5. StackGen will ask you to create a working directory or set one as shown below:

    Configure working dir

Configure StackGen Extension

Click to view
  1. From the VS Code activity bar to the left, click the StackGen icon to launch the Explorer.

  2. Click Change Environment URL and add the URL for your StackGen environment.

    Configure URL

The Environment Configuration pane allows you to manage your StackGen environment settings. From here, you can:

  • Update PAT: Replace your Personal Access Token (PAT) used for authenticating with StackGen services.
  • Delete PAT: Remove the existing PAT from your local configuration if you no longer want the extension to connect to StackGen.
  • Change Working Directory: Select a different workspace folder where modules will be downloaded, saved, and edited.
  • Change Environment URL: Specify or update the StackGen environment base URL (for example, if you are using a self-hosted deployment or staging environment).
  1. The Modules panel at the bottom lists custom modules that are created in the Modules page. You can edit and update these. To sync modules from the StackGen Web UI, simply click the refresh icon in the Infrastructure menu.

    Configure URL

  2. Alternatively, you can also click Open in IDE from the StackGen Web UI and select Open in VSCode.

    Configure URL

  3. Your Module code will look something like this:

    Configure URL

  4. You can make your changes and hit Save. These changes will now be reflected in the StackGen Web UI Code Editor, and you can visualize the same in the Preview pane.

    Configure URL

    Clicking the icons will perform the following actions:

    • 🔗 Link: This will redirect you to the module editor page in the StackGen Web UI.
    • >_ Terminal: Run the Terraform commands for the module.
    • 💾 Save: Save your changes in the working project folder in your system and sync it back to StackGen, where your module is created and stored.
    • ☁️ Download: Download the module to your system.