Skip to content

allocate-engineering/stax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stax

A powerful infrastructure automation tool that provides enhanced Terraform workflows and template management capabilities.

This tool is HEAVILY influenced by Stacks from the Cisco ThousandEyes team.

Features

  • Terraform Wrapper: Enhanced Terraform execution with additional functionality
  • Template Engine: Go text templates with Sprig functions for dynamic configuration generation
  • Configuration Management: Flexible configuration via YAML files and environment variables
  • Modular Architecture: Clean separation of concerns with dedicated modules

Installation

From Source

git clone https://github.com/allocate-engineering/stax.git
cd stax
go build -o stax

Usage

Basic Usage

# Initialize Stax configuration
cp .stax.yaml.example .stax.yaml

# Run terraform commands through Stax
stax terraform init
stax terraform plan
stax terraform apply

Command Line Options

# Use custom config file
stax --config /path/to/config.yaml terraform plan

# Pass terraform-specific flags
stax terraform plan --var-file=terraform.tfvars --dry-run

Configuration

Stax uses YAML configuration files. By default, it looks for .stax.yaml in the current directory or $HOME/.stax.yaml.

Example Configuration

terraform:
  binary: "terraform"
  default_args:
    - "-auto-approve"
  environment:
    TF_LOG: "INFO"
    TF_IN_AUTOMATION: "true"

templates:
  directory: "./templates"
  output_dir: "./output"
  variables:
    environment: "development"
    region: "us-west-2"
  default_data:
    project_name: "my-project"
    owner: "devops-team"

Template System

Stax includes a powerful template engine built on Go's text/template package with Sprig functions.

Template Directory Structure

templates/
├── main.tf.tmpl
├── variables.tf.tmpl
└── outputs.tf.tmpl

Example Template

# main.tf.tmpl
resource "aws_instance" "{{ .instance_name }}" {
  ami           = "{{ .ami_id }}"
  instance_type = "{{ .instance_type | default "t3.micro" }}"
  
  tags = {
    Name        = "{{ .project_name }}-{{ .environment }}"
    Environment = "{{ .environment }}"
    Owner       = "{{ .owner }}"
    CreatedAt   = "{{ now | date "2006-01-02T15:04:05Z07:00" }}"
  }
}

Project Structure

stax/
├── cmd/                    # Cobra commands
│   ├── root.go            # Root command configuration
│   └── terraform.go       # Terraform wrapper command
├── internal/              # Internal modules
│   ├── terraform/         # Terraform execution logic
│   ├── template/          # Template engine
│   └── config/            # Configuration management
├── templates/             # Template files (user-defined)
├── go.mod                 # Go module definition
├── main.go               # Application entry point
├── .stax.yaml.example    # Example configuration
└── README.md             # This file

Development

Prerequisites

  • Go 1.21 or later
  • Terraform (for terraform wrapper functionality)

Dependencies

  • Cobra - CLI framework
  • Viper - Configuration management
  • Sprig - Template functions

Building

go mod tidy
go build -o stax

Testing

go test ./...

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Golang reimaginging of cisco-open/stacks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors