Skip to main content
⏳ Estimated read time: 5 min read

Custom Module

Custom Modules in StackGen allow you to define and manage infrastructure components that are not natively available through cloud providers. This feature extends StackGen's capabilities, enabling the modeling and deployment of unique infrastructure tailored to specific use cases.

Key Features

  • Define Custom Infrastructure: Model infrastructure components beyond standard cloud offerings.
  • Seamless Integration: Integrate custom modules with existing resources in your topology.
  • Version Control: Manage module changes through versioning for traceability.
  • Cross-Platform Support: Create custom modules for AWS, Azure, GCP, and Helm charts.
  • Reusability: Save and reuse custom module templates across different projects.

Custom Module Actions

You can perform the following actions on a custom module:

note

Only Admin and DevOps users can create, modify (through versioning), or delete custom modules.

Developer users have read-only access, they can use shared custom modules within the topology canvas but cannot create, import, edit, or delete them.

Create

You can create a custom module using two methods:

Copy-Paste Terraform Code

If you have Terraform code ready, you can manually input it while creating a custom module.

  1. Navigate to the topology canvas of an appStack.
  2. Click Add New Resource, and select Custom Module.
  3. Choose Copy-paste TF code.
  4. Paste your Terraform configuration in the Module Configuration IaC section.
  5. Optionally, configure Custom Provider details and define Configuration Variables. Learn more about custom providers.
  6. Click Create to add the custom module to the topology.

Source from Git Repository

If your Terraform configuration is stored in a Git repository, you can import it directly.

  1. Navigate to the topology editor of an appStack.
  2. Click Add New Resource, and select Custom Module.
  3. Choose Source from Git Repository.
  4. Provide the Git Repository URL containing the Terraform code.
  5. Select the Branch, Commit, or Tag to pull the correct version.
  6. Add a Secret Token from the Secret Store to authenticate with the repository.
  7. Specify a Subdirectory if the Terraform code is not in the root folder.
  8. Click Create to import and configure the custom module.

Modify

Custom modules can be modified only through versioning. Unlike general resources, there is no Configure Module panel for direct changes.

  1. Create a new version of the custom module.
  2. Apply changes in the new version, such as updating configuration or attributes.
  3. Switch between versions or revert to previous ones as needed.

Default Version

When a custom module is overridden in an appStack, the latest semantic version is applied by default. DevOps and Admin roles can also manually peg a specific version to be used as the default for resource overrides. This ensures consistent and controlled usage of approved module versions across deployments.

Delete

DevOps and Admin roles can delete custom modules from StackGen, provided those modules are not actively referenced in any configurations.

To delete a custom module:

  1. Right-click on the module within the Topology Canvas.
  2. Select Delete Resource.
  3. Confirm the deletion when prompted.

Modules can only be deleted if:

  • They are not referenced in custom policies, governance configurations, or appStacks.
  • They are not used in any active override mapping.

If a module or a specific version is in use, StackGen will prevent deletion and display an error indicating where the module is currently referenced.

Custom Module Connection Behaviour

The Resource Connection Behaviour Table outlines how resource connections—including custom modules—behave within StackGen. This helps you understand the impact of specific configurations.

ActionResultNotes
Connecting to IAM RoleGrants necessary permissions to the moduleEnsure least privilege policies apply
Linking Database to AppEnables data flow between app and databaseVerify networking configurations
Unlinking a ResourceRemoves dependency, may impact service deliveryValidate before unlinking critical paths
Assigning Security GroupApplies rules to the connected module/resourceCheck for overlapping rules
Adding Environment VariablePropagates the variable to connected componentsUse consistent naming conventions

Imported TFState Linkage

When a Terraform state file is imported into StackGen, any resources provisioned by a multi-resource custom module are automatically grouped under that module.

Custom module linkages

  • If the custom module already exists in StackGen, the imported resources are linked to it and can be managed using versioning and governance policies.

  • If the module is not present in StackGen, the resources are still grouped under the module name, but module management features (like upgrades) are unavailable.

This ensures that imported infrastructure maintains structural and organizational consistency, especially during brownfield onboarding.

Additional Information

View Custom Modules

Custom modules are accessible within the Topology Canvas under the Custom tab. They are also included in exported Infrastructure as Code (IaC) files as follows:

  • Terraform modules listed under the modules/ directory.
  • Helm modules stored in the charts/ directory or referenced in Chart.yaml.

Output Requirements

Custom modules must output a Resource Name to ensure compatibility with IAM roles and support connections within StackGen.

LimitationDetails
Immutable VersionsExisting versions cannot be edited; create a new version to apply changes.
Limited Policy SupportCustom modules do not inherit governance policies from StackGen templates.
No Cross-ReferencingYou cannot reference other topology components from within custom modules.
Policy EvaluationNot currently supported for custom modules.
IAM DependenciesMust output a Resource Name to establish IAM connections.
No VariablizationCannot convert configuration into runtime variables.