You will need a StackGen Admin or DevOps access to run this command.
custom-modules
The stackgen upload custom-modules
command allows you to extend StackGen's capabilities by uploading definitions for your own custom resource types, enabling you to integrate specialized resources into your infrastructure.
Custom resources have been renamed to custom modules. For more info on Custom Modules, refer to Custom Modules page.
Supported Clouds
All cloud providers.
Usage
stackgen upload custom-modules [flags]
Flags
Flag | Description |
---|---|
-d, --dir string | Directory to scan for custom modules. (default "/home/user") |
-h, --help | Help for custom-modules. |
--iac-type string | IAC type for the custom modules. (default "Terraform") |
-p, --provider string | Provider for the custom modules. |
--recursive | Recursively upload custom modules from the specified directory. |
--repo-url string | Repository URL for the custom modules. |
-t, --scm-token string | SCM token for authentication. |
--tag string | Tag value for the custom modules. |
Global Flags
Flag | Description |
---|---|
-i, --interactive | Run CLI in interactive mode. |
--log int | Set log level: 2: DEBUG, 3: INFO, 4: WARN, 5: ERROR (default 3) |
-o, --output string | Command output format (json, human, raw) (default "human") |
--team string | The UUID of the team. Can also be set using the TEAM environment variable. |
Examples
Upload custom resource definitions from the current directory
stackgen upload custom-modules .
This command will:
- Scan the current directory for custom resource definitions,
- Upload these definitions to the StackGen platform,
- Make them available for use in your topologies.
Uploading from Git Repositories
If you encounter naming conflicts or need to manage multiple custom modules with complex dependencies, uploading directly from a Git repository offers a more structured approach.
stackgen upload custom-modules \
--log 2 \
-p <CLOUD_PROVIDER> \
--recursive \
--tag <TAG> \
--repo-url https://github.com/sg-tf-demo-org/gcp-mods
This approach is particularly useful when:
- You have many custom modules with interdependencies.
- Your organization maintains a central repository of approved custom modules.
- You need consistent versioning across multiple modules.
- You're encountering naming conflicts with local file uploads.
GitHub Enterprise Requirements
When using GitHub Enterprise, you may need to allowlist StackGen's egress IP addresses in your corporate firewall settings to enable proper repository access. Contact your StackGen representative for the current list of IP addresses to allowlist.
File Format
The custom modules file should be in JSON format and define the structure and properties of your custom modules. Here's a simplified example:
{
"resources": [
{
"type": "custom_database_cluster",
"provider": "aws",
"schema": {
"required": ["cluster_size", "engine_version"],
"properties": {
"cluster_size": {
"type": "integer",
"description": "Number of nodes in the cluster"
},
"engine_version": {
"type": "string",
"description": "Database engine version"
},
"backup_retention_days": {
"type": "integer",
"default": 7,
"description": "Number of days to retain backups"
}
}
}
}
]
}
- Custom modules can fill gaps in the standard resource library.
- Ensure your custom resource definitions follow the required schema format.
- You can reference existing resources as dependencies in your custom modules.