Skip to main content

Check out Port for yourselfย 

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 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 config set port:baseUrl <baseUrl>
Selecting a Port API URL by account region

The baseUrl, port_region, port.baseUrl, portBaseUrl, port_base_url and OCEAN__PORT__BASE_URL parameters are used to select which instance or Port API will be used.

Port exposes two API instances, one for the EU region of Port, and one for the US region of Port.

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.

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.