Timer
Timer is a data type used to define an expiration date/lifespan of a specific entity.
Common usage
Use timer properties to track deadlines that can trigger automation, such as:
- The expiration of a temporary development environment.
- The end of temporary resource access.
- A scheduled cleanup time for cloud resources.
A timer emits a timer-expired event when its deadline passes. Configure an automation to perform cleanup or revoke access; the timer itself does not perform those actions.
API definition
Set the property value on each entity to a future timestamp. Avoid a fixed blueprint default that will eventually be in the past.
- Basic
{
"myTimerProp": {
"title": "My timer",
"icon": "My icon",
"description": "My timer property",
"type": "string",
"format": "timer"
}
}
Check out Port's API reference to learn more.
Terraform definition
The examples below use version 2.29.0 of the Terraform and Pulumi providers. Configure your provider first, then run one example at a time in its own project. Each example creates a blueprint; use distinct identifiers when you combine examples.
- Basic
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
string_props = {
"myTimerProp" = {
title = "My timer"
icon = "My icon"
description = "My timer property"
format = "timer"
}
}
}
}
Pulumi definition
- Basic
- Python
- TypeScript
- JavaScript
- Go
"""A Python Pulumi program"""
import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertiesStringPropsArgs
blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
string_props={
"myTimerProp": BlueprintPropertiesStringPropsArgs(
title="My timer",
format="timer",
required=True,
)
}
),
relations={}
)
import * as pulumi from "@pulumi/pulumi";
import * as port from "@port-labs/port";
export const blueprint = new port.Blueprint("myBlueprint", {
identifier: "myBlueprint",
title: "My Blueprint",
properties: {
stringProps: {
myTimerProp: {
title: "My timer",
format: "timer",
required: true,
},
},
},
});
"use strict";
const pulumi = require("@pulumi/pulumi");
const port = require("@port-labs/port");
const entity = new port.Blueprint("myBlueprint", {
title: "My Blueprint",
identifier: "myBlueprint",
properties: {
stringProps: {
myTimerProp: {
title: "My timer",
format: "timer",
required: true,
},
},
},
relations: {},
});
exports.title = entity.title;
package main
import (
"github.com/port-labs/pulumi-port/sdk/v2/go/port"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
blueprint, err := port.NewBlueprint(ctx, "myBlueprint", &port.BlueprintArgs{
Identifier: pulumi.String("myBlueprint"),
Title: pulumi.String("My Blueprint"),
Properties: port.BlueprintPropertiesArgs{
StringProps: port.BlueprintPropertiesStringPropsMap{
"myTimerProp": &port.BlueprintPropertiesStringPropsArgs{
Title: pulumi.String("My timer"),
Format: pulumi.String("timer"),
Required: pulumi.Bool(true),
},
},
},
})
if err != nil {
return err
}
ctx.Export("blueprint", blueprint.Title)
return nil
})
}
Example
Here is an entity for a timerExample blueprint which has a timer property with the identifier timer.
In the example entity, an expiration datetime is specified:
"identifier": "entityIdentifier",
"title": "Timer Example",
"icon": "Microservice",
"blueprint": "timerExample",
"properties": {
"timer": "2022-12-01T16:50:00+02:00"
},
"relations": {}
Looking at Port's UI, we can see that the timer we created expires in 2 hours:

After 2 hours pass, the property status will change to Expired, and an event of Timer Expired will be sent to the ChangeLog:

The timer expiration event will also appear in Port's audit log:

In order to notify about the timer expiration, the following notification body will be sent to the Webhook/Kafka topic configured in the blueprint's changelogDestination:
{
"context": {
"blueprint": "timerExample",
"entity": "entityIdentifier"
},
"action": "TIMER_EXPIRED",
"trigger": {
"at": "2022-12-01T16:50:00+02:00",
"by": {
"byPort": true,
"orgId": "org_example"
},
"origin": "API"
},
"resourceType": "entity",
"status": "SUCCESS"
}