Manually created topology import/export

With StackState it is possible to export components and relations that were created manually, i.e. components and relations that are not synchronized via StackPacks. This page describes to process of exporting and importing selective topology data.




  1. Open StackState
  2. Open Explore mode, or use an existing view as starting point.
  3. Construct a view visualizing only the topology that is intended for export. Topology selection can either be done by filtering on component names or by filtering out the topology that is synchronized from StackPacks. Filtering can done in basic or advanced mode. Components that are synchronized from StackPacks have labels in format stackpack:<StackPack name>. A STQL query can be written to filter synchronized topology from StackPacks. For example, to filter out AWS synchronized components the STQL would be NOT (label IN ("stackpack:AWS")).
  4. Copy the STQL query as shown in the advanced mode of the filtering pane.
  5. With the use of the STQL query we can execute the following shell commands to create an export of the topology, components and relations. Substitute <STQL Query> for the query obtained in the previous step.
sts script execute -t 15 "Topology.query('<STQL Query>').then { def result = it.queryResults.result; def ids = (result.components + result.relations).collect { }; ids.flatten() }" | xargs sts graph export --ids

Note: mind the escaping of quotes when inserting the STQL Query in the command.

Example, to filter out topology that is synchronized from the AWS StackPack:

sts script execute -t 15 "Topology.query('NOT (label IN (\"stackpack:AWS\"))').then { def result = it.queryResults.result; def ids = (result.components + result.relations).collect { }; ids.flatten() }" | xargs sts graph export --ids

The output of the command can be saved in a file for later use.

Explanation of the commands:

  1. StackState is queried to retrieve the components and relations as defined in the view, based on the STQL query, by using the sts script execute command. Request timeout is set to 15 seconds as retrieval may consume some time.
  2. The response is filtered to obtain a list of the to be exported StackState component and relation identifiers.
  3. An export of StackState data is made by providing the identifiers to the sts graph export command.


Importing previous topology information can be done with the following command. Assuming that the file backupFile contains the contents from the export section.

cat backupFile | sts graph import