Skip to main content

Transformation

A Transformation is a generic plugin to transform a dataset into a different format to simplify it's ingestion by third-party systems.

The output of a transformation can be either in JSON format or in plain text.

Currently transformations must be written in Python or Jinja2, but in the future more languages could be supported.

Examples
  • With the Jinja Plugin it's possible to generate any configuration files, in plain text format.
  • With the Python Plugin it's possible to generate the payload expected by CloudFormation to configure a resource in AWS.

High level design

A transformation is composed of 2 main components:

  • A GraphQL query that will define what the input data is.
  • A Transformation logic that will process the data and transform it.

The transformation will automatically inherit the parameters (variables) defined by the GraphQL query. Depending on how the GraphQL query has been constructed, a transformation can be static or work for multiple objects.

Common parameters
NameTypeDefaultRequired
nameText-Yes
labelText-No
descriptionText-No
timeoutNumber10No
rebaseBooleanFalseNo
queryRelationship
CoreGraphQLQuery
-Yes
repositoryRelationship
CoreRepository
-Yes

Available transformations

NamespaceTransformationDescriptionLanguageOutput Format
CoreTransformJinja2A file rendered from a Jinja2 templateJinja2Plain Text
CoreTransformPythonA transform function written in PythonPythonJSON

Rendered file (Jinja2 plugin)

Infrahub can natively render any Jinja templates dynamically. Internally it's referred to as TransformJinja2. It can generate any file in plain text format and must be composed of 1 main Jinja2 template and 1 GraphQL query.

Create a Jinja rendered transform

Please refer to the guide Creating a Jinja Rendered Transform for more information.

Render a Jinja2 transform

A Jinja2 Transform can be rendered with 3 different methods:

TransformPython (Python plugin)

A TransformPython is a transformation plugin written in Python. It can generate any dataset in JSON format and must be composed of 1 main Python Class and 1 GraphQL Query.

Create a Python transform

A TransformPython must be written as a Python class that inherits from InfrahubTransform and it must implement one transform method. The transform method must accept a dict and return one.

Please refer to the guide Creating a Python transform for more information.

Render a TransformPython

A TransformPython can be rendered with 2 different methods:

Unit testing for transformation

Infrahub provide a framework to create unit tests for your transformations with very minimal code/configuration.

The tests can be executed locally for development purpose and they will also be executed as part of the CI Pipeline when the platform identify a change that could potentially impact your transformation.

For more information, please check out the Resource Testing Framework page.