Skip to main content
⏳ Estimated read time: 3 min read
Important

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.

note

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

FlagDescription
-d, --dir stringDirectory to scan for custom modules. (default "/home/user")
-h, --helpHelp for custom-modules.
--iac-type stringIAC type for the custom modules. (default "Terraform")
-p, --provider stringProvider for the custom modules.
--recursiveRecursively upload custom modules from the specified directory.
--repo-url stringRepository URL for the custom modules.
-t, --scm-token stringSCM token for authentication.
--tag stringTag value for the custom modules.

Global Flags

FlagDescription
-i, --interactiveRun CLI in interactive mode.
--log intSet log level: 2: DEBUG, 3: INFO, 4: WARN, 5: ERROR (default 3)
-o, --output stringCommand output format (json, human, raw) (default "human")
--team stringThe 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"
}
}
}
}
]
}
note
  • 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.