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

Generate IaC with a GitHub Action

This document provides instructions on how to use the StackGen Generative IaC action in a GitHub Action workflow to generate Infrastructure as Code (IaC).

For more details, visit the Generate Action Documentation.

Prerequisites

Before you begin, complete the following setup steps:

  1. Sign up for an account on StackGen Visit the StackGen website and create an account.

  2. Generate a Personal Access Token (PAT) on StackGen Follow the StackGen documentation to create a new Personal Access Token.

  3. Add the Personal Access Token to your repository Store your Personal Access Token as a secret in your GitHub repository with the name STACKGEN_TOKEN.

Configuration

The StackGen action can be configured with several inputs to customize the IaC generation process. Below is a summary of the available inputs:

InputDescriptionDefault Value
cloudSpecify the cloud provider (e.g., aws, azure).aws
languageSet the programming language (e.g., Python, Java). Default behavior is auto-detection based on file extensions.auto-detect
outputDirDefine the output directory for the generated IaC../iac
scanPathIndicate the path to scan for the application.. (current directory)
targetComputeChoose the target compute platform (e.g., k8s, ecs).k8s
cleanupDecide whether to clean up the StackGen mothership after the action.true

Usage

To use the StackGen Generative IaC action in your GitHub Actions workflow, add the following step to your .github/workflows YAML file:

- name: Generate IaC
uses: appcd-dev/generate-action@v0
env:
STACKGEN_TOKEN: ${{ secrets.STACKGEN_TOKEN }}
with:
cloud: 'aws' # Specify the cloud provider
language: 'Python' # Set the programming language
outputDir: './iac' # Define the output directory
scanPath: '.' # Indicate the path to scan
targetCompute: 'k8s' # Choose the target compute platform
cleanup: 'true' # Cleanup after action