Terraform Provider - allow adding aggregate properties to _team
M
Mark Tarry
We are currently unable to define aggregate properties for the
_team
system blueprint via the Terraform Provider.Example Terraform resource:
resource "port_aggregation_properties" "team-aggregations" {
blueprint_identifier = "_team"
properties = {
metric_avg_deployment_frequency = {
target_blueprint_identifier = "github-repository"
title = "Deployment Frequency"
method = {
average_by_property = {
average_of = "total"
measure_time_by = "$createdAt"
property = "metric_avg_deployment_frequency"
}
}
path_filter = [
{
from_blueprint = "github-repository"
path = ["$team"]
}
]
}
}
}
When running
terraform apply
this generates the following error:│ Error: failed to create aggregation properties
│
│ with module.data-model.port_aggregation_properties.team-aggregations,
│ on data-model/teams.tf line 50, in resource "port_aggregation_properties" "team-aggregations":
│ 50: resource "port_aggregation_properties" "team-aggregations" {
│
│ failed to create blueprint, got:
│ {"ok":false,"error":"protected_blueprint_violation","message":"The property
│ size of Team blueprint cannot be modified","details":{"blueprint":"Team"}}
The
size
property is not under our control - it's part of the system blueprint.We cannot add the
size
aggregation to the Terraform resource, as the Terraform provider then attempts to create it - when it already exists:resource "port_aggregation_properties" "team-aggregations" {
blueprint_identifier = "_team"
properties = {
# This aggregation is defined by Port - as part of the _team system-managed blueprint
size = {
target_blueprint_identifier = "_user"
title = "Size"
method = {
count_entities = true
}
}
# ...etc
}
}
╷
│ Error: aggregation property already exists
│
│ with module.data-model.port_aggregation_properties.team-aggregations,
│ on data-model/teams.tf line 50, in resource "port_aggregation_properties" "team-aggregations":
│ 50: resource "port_aggregation_properties" "team-aggregations" {
│
│ size
╵
M
Mark Tarry
Since raising this, I've found this post in the Slack #community-help channel: https://port-community.slack.com/archives/C07CB3MV63G/p1723208630411719
It does appear possible to workaround this via Terraform
import
blocks/commands. E.g.import {
id = "_team"
to = port_aggregation_properties.team-aggregations
}
However, in addition we still have to explicitly define the
size
aggregate within our Terraform resource:resource "port_aggregation_properties" "team-aggregations" {
blueprint_identifier = "_team"
properties = {
# This aggregation is defined by Port - as part of the _team system-managed blueprint
size = {
target_blueprint_identifier = "_user"
title = "Size"
method = {
count_entities = true
}
}
# ...etc
}
}
If we don't do this, then Terraform imports the state, identifies the aggregate is not present, and attempts to remove it.
This isn't ideal as:
- we now have Terraform src code managing an aggregate that we have no real control over
- if Port introduce changes to this aggregate, or adds other aggregates to the _teamblueprint, then our Terraform deployments start failing again - or worse, start breaking the system blueprint
M
Mark Tarry
I have not confirmed if the same limitation applies to the
_user
blueprint - although my assumption is not, as that system blueprint doesn't appear to have any aggregate properties as yet.