Extend modules using Terrafile
masterTerrafile. The Terrafile is the configuration point for managing module dependencies within the Terraspace framework.repository·master·Indexed 20 days ago
https://github.com/boltops-tools/terraspaceA Terraform framework designed for DRY, scalable infrastructure management. Terraspace provides a CLI for multi-stack deployment with dependency awareness, environment layering, and module management via a Ruby-based Terrafile. It supports major cloud providers including AWS, Azure (azurerm), and GCP (google), and includes features for generating dependency graphs, managing state, and configuring global settings through the Terraspace::App class.
Terrafile. The Terrafile is the configuration point for managing module dependencies within the Terraspace framework.Timestamps behave differently depending on the scope of your log request:
up logs across multiple stacks).terraspace logs up network).To explicitly show timestamps for a single stack log, use the --timestamps flag.
terraspace logs up network --timestampsUse the terraspace import command to bring existing cloud resources into your Terraform state. The command requires the stack name, the resource address (as defined in your Terraform code), and the actual resource ID from your cloud provider.
General Workflow:
terraspace plan <stack> to identify resources that are missing from your state but exist in your configuration.terraspace import <stack> <resource_address> <resource_id> to import the specific resource.terraspace plan <stack> again to verify that the resource is now correctly managed and no longer shows as 'to be created'.terraspace state list <stack> to inspect your current state.# Import an EC2 instance
terraspace import ec2 aws_instance.this i-088a0a47e2e852cc8
# Import a VPC module resource
terraspace import vpc module.vpc.aws_vpc.this vpc-000782e4951a734c7
# Import a resource with an index (e.g., an element in a list)
terraspace import vpc module.vpc.aws_internet_gateway.this[0] igw-0fa4bec3b4b46948aTerraspace provides simple commands to manage the lifecycle of your infrastructure stacks.
terraspace up <stack_name>: Builds the stack in a cache directory and runs terraform init and terraform apply.terraspace down <stack_name>: Builds the stack in a cache directory and runs terraform destroy to clean up resources.# Deploy a specific stack
terraspace up demo
# Destroy a specific stack
terraspace down demoThe terraspace all up command orchestrates the deployment of multiple stacks by grouping them into batches. Terraspace executes these batches in parallel to optimize deployment time. Before execution, Terraspace displays a list of the commands it will run and asks for confirmation.
After deployment, Terraspace provides a summary of the runs and the total time taken. Detailed logs for each stack are written to the log/up/<stack_name>.log directory for debugging. You can use the terraspace log command to view these logs.
$ terraspace all up
# Terraspace will list batches and ask: Are you sure? (y/N)
# Example output:
# Batch Run 1:
# Running: terraspace up c1 Logs: log/up/c1.log
# terraspace up c1: Apply complete! Resources: 1 added, 0 changed, 0 destroyed.To enable TAB auto-completion for Terraspace commands and arguments in your shell, add the following command to your shell profile (e.g., .bashrc, .zshrc, or .bash_profile):
eval $(terraspace completion_script)Once enabled, you can use the [TAB] key to autocomplete commands like terraspace up [TAB], stack names terraspace up name [TAB], or flags terraspace up name --[TAB].
Use the terraspace new shim command to generate a Terraspace shim. This shim is typically installed at /usr/local/bin/terraspace.
After generation, ensure that /usr/local/bin is included in your system $PATH so the terraspace command can be executed from any terminal session. You can verify the installation by running which terraspace.
$ terraspace new shimTo follow logs as they are generated (similar to tail -f), use the -f option. This is useful when running long-running operations like terraspace all up. Terraspace automatically checks for new logs every second and adds them to the stream.
terraspace logs -fIf the terraspace command is not found after generating the shim, you may need to manually add /usr/local/bin to your $PATH.
To do this permanently in a Bash environment, add the following line to your ~/.bash_profile and restart your terminal:
export PATH=/usr/local/bin:$PATHUse the terraspace new plugin command to scaffold a new Terraspace plugin. This command generates a complete directory structure including Ruby templates, HCL templates, RSpec test suites, and necessary configuration files (like .gemspec, Gemfile, and Rakefile) to allow you to build custom provider logic for Terraspace.
The generated structure includes:
backend, config, expander, and layer.$ terraspace new plugin mycloudTo get started with Terraspace, you can generate a starter project using the new command, which includes examples and a specified cloud provider plugin. Once the project is created, you can use up to deploy a stack and down to destroy it.
Supported major cloud providers include aws, azurerm (Azure), and google (GCP).
# Generate a new project with AWS plugin and examples
terraspace new project infra --plugin aws --examples
# Navigate to the project
cd infra
# Deploy a demo stack
terraspace up demo
# Clean up and delete the demo stack
terraspace down demoUse the terraspace check_setup command to verify that your environment meets the necessary requirements. This command checks your current Terraspace version and ensures that your installed Terraform binary is version v0.12.x or above.
$ terraspace check_setup