Stacktape uses a configuration file to define your infrastructure. You can write it in TypeScript (recommended), YAML, or JSON.
TypeScript Configuration
TypeScript gives you full type safety, autocomplete, and the ability to use programming logic.
Basic Structure
Create a stacktape.ts file in your project root:
The defineConfig function receives context about the deployment:
stage- The stage name (e.g.,dev,production)region- The AWS region being deployed toprojectName- The project name
Using TypeScript Logic
The power of TypeScript is that you can use real programming constructs:
YAML Configuration
If you prefer YAML, create a stacktape.yml file:
Dynamic Values with Directives
YAML configurations can use directives for dynamic values:
Common directives:
$Stage()- Current stage name$Region()- Current AWS region$ResourceParam('resourceName', 'property')- Reference another resource's property$Secret('secretName')- Reference a secret from your secrets store$Format('template {}', $Stage())- String formatting
Connecting Resources
The connectTo property automatically:
- Injects environment variables with connection details
- Grants necessary IAM permissions
- Configures security group rules for network access
The injected environment variables follow a naming convention:
STP_<RESOURCE_NAME>_CONNECTION_STRINGSTP_<RESOURCE_NAME>_HOSTSTP_<RESOURCE_NAME>_PORT
Environment Variables
Set environment variables directly on your resources:
Scripts and Hooks
Define reusable scripts for tasks like database migrations:
Run scripts manually:
Extending with CloudFormation
Add any AWS resource using raw CloudFormation:
Overriding Resource Properties
Override any underlying CloudFormation property:
Or use transforms for more control:
Interactive Config Editor
For YAML configurations, use the web-based Interactive Config Editor:
- Visual resource builder with presets
- Real-time validation and error checking
- Cost estimation
- Auto-completion for all properties
- Preview of generated CloudFormation
The VS Code extension also provides autocomplete and validation for YAML configs.