page_title | subcategory | description |
---|---|---|
port_aggregation_properties Resource - terraform-provider-port-labs |
Aggregation Properties
This resource allows you to manage aggregation properties of a blueprint.
See the Port documentation https://docs.getport.io/build-your-software-catalog/define-your-data-model/setup-blueprint/properties/aggregation-properties/ for more information about aggregation properties.
Supported Methods:
count_entities - Count the entities of the target blueprintaverage_entities - Average the entities of the target blueprint by time periodsaveragebyproperty - Calculate the average by property value of the target entitiesaggregatebyproperty - Calculate the aggregate by property value of the target entities, such as sum, min, max, median
Example Usage
Create a parent blueprint with a child blueprint and an aggregation property to count the parent kids:
```hcl
resource "portblueprint" "parentblueprint" {
title = "Parent Blueprint"
icon = "Terraform"
identifier = "parent"
description = ""
properties = {
number_props = {
"age" = {
title = "Age"
}
}
}
}
resource "portblueprint" "childblueprint" {
title = "Child Blueprint"
icon = "Terraform"
identifier = "child"
description = ""
properties = {
numberprops = {
"age" = {
title = "Age"
}
}
}
relations = {
"parent" = {
title = "Parent"
target = portblueprint.parent_blueprint.identifier
}
}
}
resource "portaggregationproperties" "parentaggregationproperties" {
blueprintidentifier = portblueprint.parentblueprint.identifier
properties = {
"countkids" = {
targetblueprintidentifier = portblueprint.childblueprint.identifier
title = "Count Kids"
icon = "Terraform"
description = "Count Kids"
method = {
count_entities = true
}
}
}
}
```
Create a parent blueprint with a child blueprint and an aggregation property to calculate the average avg of the parent kids age:
```hcl
resource "portblueprint" "parentblueprint" {
title = "Parent Blueprint"
icon = "Terraform"
identifier = "parent"
description = ""
properties = {
number_props = {
"age" = {
title = "Age"
}
}
}
}
resource "portblueprint" "childblueprint" {
title = "Child Blueprint"
icon = "Terraform"
identifier = "child"
description = ""
properties = {
numberprops = {
"age" = {
title = "Age"
}
}
}
relations = {
"parent" = {
title = "Parent"
target = portblueprint.parent_blueprint.identifier
}
}
}
resource "portaggregationproperties" "parentaggregationproperties" {
blueprintidentifier = portblueprint.parentblueprint.identifier
properties = {
averagekidsage = {
targetblueprintidentifier = portblueprint.childblueprint.identifier
title = "Average Kids Age"
icon = "Terraform"
description = "Average Kids Age"
method = {
averagebyproperty = {
averageof = "total"
measuretimeby = "$createdAt"
property = "age"
}
}
}
}
}
```
Create a repository blueprint and a pull request blueprint and an aggregation property to calculate the average of pull requests created per day:
```hcl
resource "portblueprint" "repositoryblueprint" {
title = "Repository Blueprint"
icon = "Terraform"
identifier = "repository"
description = ""
}
resource "portblueprint" "pullrequestblueprint" {
title = "Pull Request Blueprint"
icon = "Terraform"
identifier = "pullrequest"
description = ""
properties = {
stringprops = {
"status" = {
title = "Status"
}
}
}
relations = {
"repository" = {
title = "Repository"
target = portblueprint.repository_blueprint.identifier
}
}
}
resource "portaggregationproperties" "repositoryaggregationproperties" {
blueprintidentifier = portblueprint.repositoryblueprint.identifier
properties = {
"pullrequestsperday" = {
targetblueprintidentifier = portblueprint.pullrequestblueprint.identifier
title = "Pull Requests Per Day"
icon = "Terraform"
description = "Pull Requests Per Day"
method = {
averageentities = {
averageof = "day"
measuretime_by = "$createdAt"
}
}
}
}
}
```
Create a repository blueprint and a pull request blueprint and an aggregation property to calculate the average of fix pull request per month:
To do that we will add a query to the aggregation property to filter only pull requests with fixed title:
```hcl
resource "portblueprint" "repositoryblueprint" {
title = "Repository Blueprint"
icon = "Terraform"
identifier = "repository"
description = ""
}
resource "portblueprint" "pullrequestblueprint" {
title = "Pull Request Blueprint"
icon = "Terraform"
identifier = "pullrequest"
description = ""
properties = {
stringprops = {
"status" = {
title = "Status"
}
}
}
relations = {
"repository" = {
title = "Repository"
target = portblueprint.repository_blueprint.identifier
}
}
}
resource "portaggregationproperties" "repositoryaggregationproperties" {
blueprintidentifier = portblueprint.repositoryblueprint.identifier
properties = {
"fixpullrequestscount" = {
targetblueprintidentifier = portblueprint.pullrequestblueprint.identifier
title = "Pull Requests Per Day"
icon = "Terraform"
description = "Pull Requests Per Day"
method = {
averageentities = {
averageof = "month"
measuretime_by = "$createdAt"
}
}
query = jsonencode(
{
"combinator" : "and",
"rules" : [
{
"property" : "$title",
"operator" : "ContainsAny",
"value" : ["fix", "fixed", "fixing", "Fix"]
}
]
}
)
}
}
}
```
Create multiple aggregation properties in one resource:
```hcl
resource "portblueprint" "repositoryblueprint" {
title = "Repository Blueprint"
icon = "Terraform"
identifier = "repository"
description = ""
}
resource "portblueprint" "pullrequestblueprint" {
title = "Pull Request Blueprint"
icon = "Terraform"
identifier = "pullrequest"
description = ""
properties = {
stringprops = {
"status" = {
title = "Status"
}
}
}
relations = {
"repository" = {
title = "Repository"
target = portblueprint.repository_blueprint.identifier
}
}
}
resource "portaggregationproperties" "repositoryaggregationproperties" {
blueprintidentifier = portblueprint.repositoryblueprint.identifier
properties = {
"pullrequestsperday" = {
targetblueprintidentifier = portblueprint.pullrequestblueprint.identifier
title = "Pull Requests Per Day"
icon = "Terraform"
description = "Pull Requests Per Day"
method = {
averageentities = {
averageof = "day"
measuretimeby = "$createdAt"
}
}
}
"overallpullrequestscount" = {
targetblueprintidentifier = portblueprint.pullrequestblueprint.identifier
title = "Overall Pull Requests Count"
icon = "Terraform"
description = "Overall Pull Requests Count"
method = {
countentities = true
}
}
}
}
``` |
This resource allows you to manage aggregation properties of a blueprint.
See the Port documentation for more information about aggregation properties.
Supported Methods:
- count_entities - Count the entities of the target blueprint
- average_entities - Average the entities of the target blueprint by time periods
- average_by_property - Calculate the average by property value of the target entities
- aggregate_by_property - Calculate the aggregate by property value of the target entities, such as sum, min, max, median
Create a parent blueprint with a child blueprint and an aggregation property to count the parent kids:
resource "port_blueprint" "parent_blueprint" {
title = "Parent Blueprint"
icon = "Terraform"
identifier = "parent"
description = ""
properties = {
number_props = {
"age" = {
title = "Age"
}
}
}
}
resource "port_blueprint" "child_blueprint" {
title = "Child Blueprint"
icon = "Terraform"
identifier = "child"
description = ""
properties = {
number_props = {
"age" = {
title = "Age"
}
}
}
relations = {
"parent" = {
title = "Parent"
target = port_blueprint.parent_blueprint.identifier
}
}
}
resource "port_aggregation_properties" "parent_aggregation_properties" {
blueprint_identifier = port_blueprint.parent_blueprint.identifier
properties = {
"count_kids" = {
target_blueprint_identifier = port_blueprint.child_blueprint.identifier
title = "Count Kids"
icon = "Terraform"
description = "Count Kids"
method = {
count_entities = true
}
}
}
}
Create a parent blueprint with a child blueprint and an aggregation property to calculate the average avg of the parent kids age:
resource "port_blueprint" "parent_blueprint" {
title = "Parent Blueprint"
icon = "Terraform"
identifier = "parent"
description = ""
properties = {
number_props = {
"age" = {
title = "Age"
}
}
}
}
resource "port_blueprint" "child_blueprint" {
title = "Child Blueprint"
icon = "Terraform"
identifier = "child"
description = ""
properties = {
number_props = {
"age" = {
title = "Age"
}
}
}
relations = {
"parent" = {
title = "Parent"
target = port_blueprint.parent_blueprint.identifier
}
}
}
resource "port_aggregation_properties" "parent_aggregation_properties" {
blueprint_identifier = port_blueprint.parent_blueprint.identifier
properties = {
average_kids_age = {
target_blueprint_identifier = port_blueprint.child_blueprint.identifier
title = "Average Kids Age"
icon = "Terraform"
description = "Average Kids Age"
method = {
average_by_property = {
average_of = "total"
measure_time_by = "$createdAt"
property = "age"
}
}
}
}
}
Create a repository blueprint and a pull request blueprint and an aggregation property to calculate the average of pull requests created per day:
resource "port_blueprint" "repository_blueprint" {
title = "Repository Blueprint"
icon = "Terraform"
identifier = "repository"
description = ""
}
resource "port_blueprint" "pull_request_blueprint" {
title = "Pull Request Blueprint"
icon = "Terraform"
identifier = "pull_request"
description = ""
properties = {
string_props = {
"status" = {
title = "Status"
}
}
}
relations = {
"repository" = {
title = "Repository"
target = port_blueprint.repository_blueprint.identifier
}
}
}
resource "port_aggregation_properties" "repository_aggregation_properties" {
blueprint_identifier = port_blueprint.repository_blueprint.identifier
properties = {
"pull_requests_per_day" = {
target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
title = "Pull Requests Per Day"
icon = "Terraform"
description = "Pull Requests Per Day"
method = {
average_entities = {
average_of = "day"
measure_time_by = "$createdAt"
}
}
}
}
}
Create a repository blueprint and a pull request blueprint and an aggregation property to calculate the average of fix pull request per month:
To do that we will add a query to the aggregation property to filter only pull requests with fixed title:
resource "port_blueprint" "repository_blueprint" {
title = "Repository Blueprint"
icon = "Terraform"
identifier = "repository"
description = ""
}
resource "port_blueprint" "pull_request_blueprint" {
title = "Pull Request Blueprint"
icon = "Terraform"
identifier = "pull_request"
description = ""
properties = {
string_props = {
"status" = {
title = "Status"
}
}
}
relations = {
"repository" = {
title = "Repository"
target = port_blueprint.repository_blueprint.identifier
}
}
}
resource "port_aggregation_properties" "repository_aggregation_properties" {
blueprint_identifier = port_blueprint.repository_blueprint.identifier
properties = {
"fix_pull_requests_count" = {
target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
title = "Pull Requests Per Day"
icon = "Terraform"
description = "Pull Requests Per Day"
method = {
average_entities = {
average_of = "month"
measure_time_by = "$createdAt"
}
}
query = jsonencode(
{
"combinator" : "and",
"rules" : [
{
"property" : "$title",
"operator" : "ContainsAny",
"value" : ["fix", "fixed", "fixing", "Fix"]
}
]
}
)
}
}
}
Create multiple aggregation properties in one resource:
resource "port_blueprint" "repository_blueprint" {
title = "Repository Blueprint"
icon = "Terraform"
identifier = "repository"
description = ""
}
resource "port_blueprint" "pull_request_blueprint" {
title = "Pull Request Blueprint"
icon = "Terraform"
identifier = "pull_request"
description = ""
properties = {
string_props = {
"status" = {
title = "Status"
}
}
}
relations = {
"repository" = {
title = "Repository"
target = port_blueprint.repository_blueprint.identifier
}
}
}
resource "port_aggregation_properties" "repository_aggregation_properties" {
blueprint_identifier = port_blueprint.repository_blueprint.identifier
properties = {
"pull_requests_per_day" = {
target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
title = "Pull Requests Per Day"
icon = "Terraform"
description = "Pull Requests Per Day"
method = {
average_entities = {
average_of = "day"
measure_time_by = "$createdAt"
}
}
}
"overall_pull_requests_count" = {
target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
title = "Overall Pull Requests Count"
icon = "Terraform"
description = "Overall Pull Requests Count"
method = {
count_entities = true
}
}
}
}
blueprint_identifier
(String) The identifier of the blueprint the aggregation property will be added toproperties
(Attributes Map) The aggregation property of the blueprint (see below for nested schema)
id
(String) The ID of this resource.
Required:
method
(Attributes) The aggregation method to perform on the target blueprint, one of count_entities, average_entities, average_by_property, aggregate_by_property (see below for nested schema)target_blueprint_identifier
(String) The identifier of the blueprint to perform the aggregation on
Optional:
description
(String) The description of the aggregation propertyicon
(String) The icon of the aggregation propertyquery
(String) Query to filter the target entitiestitle
(String) The title of the aggregation property
Optional:
aggregate_by_property
(Attributes) Function to calculate the aggregate by property value of the target entities, such as sum, min, max, median (see below for nested schema)average_by_property
(Attributes) Function to calculate the average by property value of the target entities (see below for nested schema)average_entities
(Attributes) Function to average the entities of the target entities (see below for nested schema)count_entities
(Boolean) Function to count the entities of the target entities
Required:
func
(String) The func of the aggregate by propertyproperty
(String) The property of the aggregate by property
Required:
average_of
(String) The time periods to calculate the average by, e.g. hour, day, week, monthmeasure_time_by
(String) The property name on which to calculate the the time periods, e.g. $createdAt, $updated_at or any other date propertyproperty
(String) The property name on which to calculate the average by
Optional:
average_of
(String) The time periods to calculate the average of, e.g. hour, day, week, monthmeasure_time_by
(String) The property name on which to calculate the the time periods, e.g. $createdAt, $updated_at or any other date property