Skip to main content

Pulumi

Our integration with Pulumi allows you to combine the state of your infrastructure with the entities representing them in Port.

By using Port's Pulumi provider you make it easy to integrate Port with your existing IaC definitions, every resource provisioned by Pulumi can also be reported to the software catalog using the same definition file.

💡 Pulumi provider common use cases​

Our Pulumi provider makes it easy to fill the software catalog with data directly from your IaC definitions, for example:

  • Report cloud accounts.
  • Report databases.
  • Report lambdas and managed Kubernetes services (EKS, AKS, GKE, etc.).

Installation​

Prerequisites

To install and use Port's Pulumi provider, you will need to install the Pulumi CLI

To install the Pulumi provider, use your preferred method of installing Pulumi providers.

pip install port_pulumi

Configuration​

Please make sure to configure the clientId and secret to Port using the commands

Get your Port credentials

To get your Port API credentials go to your Port application, click on the ... button in the top right corner, and select Credentials. Here you can view and copy your CLIENT_ID and CLIENT_SECRET:

pulumi config set port:clientId <clientId>
pulumi config set port:secret <clientSecret> --secret

Pulumi definition structure​

Port's Pulumi provider supports The following resources to ingest data to the catalog:

Entity​

The Entity resource defines a basic entity:

"""A Python Pulumi program"""

import pulumi
from port_pulumi import Entity,BlueprintPropertiesArgs

entity = Entity(
"myEntity",
title="My Entity",
blueprint="myBlueprint",
properties=BlueprintPropertiesArgs(),
relations={}
)

The following parameters are required:

  • blueprint - the identifier of the blueprint to create this entity from;
  • title - the title of the entity;
  • One or more properties schema definitions.

It is also possible to specify the following parameters as part of the port_entity resource:

  • identifier - the identifier of the entity;
    • If an identifier is not provided, an identifier will be autogenerated.
  • team - the team that owns the entity;
  • teams - an array of teams that own the entity;
  • run_id - the run ID of the action that created the entity.

properties schema​

The properties schema assigns a specified value to one of the entity's properties.

Definition​

"""A Python Pulumi program"""
from port_pulumi import Entity,EntityPropertiesArgs

entity = Entity(
"myEntity",
identifier="myEntity",
title="My Entity",
blueprint="myBlueprint",
properties=EntityPropertiesArgs(
string_props={
"myStringProp": "My string"
}
),
relations={}
)

The following parameters are required:

  • name - the name of the property in the blueprint definition;
  • value - the value of the property (for non-array properties);
  • items - an array of values (for array properties).

relations schema​

The relations schema maps a target entity to the source entity definition:

"""A Python Pulumi program"""

import json
import pulumi
from port_pulumi import Entity,EntityRelationsArgs

entity = Entity(
"myEntity",
identifier="myEntity",
title="My Entity",
blueprint="myBlueprint",
properties={},
relations=EntityRelationsArgs(
many_relations={
"myManyRelation": ["myTargetEntityIdentifier", "myTargetEntityIdentifier2"]
},
single_relations={
"mySingleRelation": "myTargetEntityIdentifier"
},
),
)

The following parameters are required:

  • name - the name of the relation in the blueprint definition;
  • identifier - the identifier of the target entity.
note

At the moment, it is only possible to create entities with many: false relations using Port's Pulumi provider.

Ingest data using the Pulumi provider​

To ingest data to the software catalog using the Pulumi provider, you will create an instance of port.Entity resource in your preferred langauge:

To create an entity using Pulumi, create a file in your prefered languague from and insert the following:

"""A Python Pulumi program"""

import pulumi
from port_pulumi import Entity

entity = Entity(
"myEntity",
title="My Entity",
blueprint="myBlueprint",
properties={},
relations={}
)

Then run the following command to apply your changes and update the catalog:

pulumi up -y

After running these commands, you will see your catalog updated with the new entities.