Skip to content

Commit 3349e80

Browse files
authored
Add aggregation property support (#97)
1 parent c079921 commit 3349e80

File tree

22 files changed

+2461
-86
lines changed

22 files changed

+2461
-86
lines changed

docs/resources/port_aggregation_property.md

Lines changed: 500 additions & 0 deletions
Large diffs are not rendered by default.

docs/resources/port_blueprint.md

Lines changed: 203 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,213 @@ page_title: "port_blueprint Resource - terraform-provider-port-labs"
44
subcategory: ""
55
description: |-
66
Blueprint Resource
7+
Docs about the blueprint resource in Port can be found here https://docs.getport.io/build-your-software-catalog/define-your-data-model/setup-blueprint/.
8+
Example Usage
9+
```hcl
10+
resource "portblueprint" "environment" {
11+
title = "Environment"
12+
icon = "Environment"
13+
identifier = "environment"
14+
properties = {
15+
stringprops = {
16+
"aws-region" = {
17+
title = "AWS Region"
18+
}
19+
"docs-url" = {
20+
title = "Docs URL"
21+
format = "url"
22+
}
23+
}
24+
}
25+
}
26+
```
27+
Example Usage with Relations
28+
```hcl
29+
resource "portblueprint" "environment" {
30+
title = "Environment"
31+
icon = "Environment"
32+
identifier = "environment"
33+
properties = {
34+
stringprops = {
35+
"aws-region" = {
36+
title = "AWS Region"
37+
}
38+
"docs-url" = {
39+
title = "Docs URL"
40+
format = "url"
41+
}
42+
}
43+
}
44+
}
45+
resource "portblueprint" "microservice" {
46+
title = "Microservice"
47+
icon = "Microservice"
48+
identifier = "microservice"
49+
properties = {
50+
stringprops = {
51+
"domain" = {
52+
title = "Domain"
53+
}
54+
"slack-channel" = {
55+
title = "Slack Channel"
56+
format = "url"
57+
}
58+
}
59+
}
60+
relations = {
61+
"environment" = {
62+
target = port_blueprint.environment.identifier
63+
required = true
64+
many = false
65+
}
66+
}
67+
}
68+
```
69+
Example Usage with Mirror Properties
70+
```hcl
71+
resource "portblueprint" "microservice" {
72+
title = "Microservice"
73+
icon = "Microservice"
74+
identifier = "microservice"
75+
properties = {
76+
stringprops = {
77+
"domain" = {
78+
title = "Domain"
79+
}
80+
"slack-channel" = {
81+
title = "Slack Channel"
82+
format = "url"
83+
}
84+
}
85+
}
86+
mirrorproperties = {
87+
"aws-region" = {
88+
path = "environment.aws-region"
89+
}
90+
}
91+
relations = {
92+
"environment" = {
93+
target = portblueprint.environment.identifier
94+
required = true
95+
many = false
96+
}
97+
}
98+
}
99+
```
7100
---
8101

9102
# port_blueprint (Resource)
10103

11-
Blueprint Resource
104+
# Blueprint Resource
105+
106+
Docs about the blueprint resource in Port can be found [here](https://docs.getport.io/build-your-software-catalog/define-your-data-model/setup-blueprint/).
107+
108+
109+
## Example Usage
110+
111+
```hcl
112+
113+
resource "port_blueprint" "environment" {
114+
title = "Environment"
115+
icon = "Environment"
116+
identifier = "environment"
117+
properties = {
118+
string_props = {
119+
"aws-region" = {
120+
title = "AWS Region"
121+
}
122+
"docs-url" = {
123+
title = "Docs URL"
124+
format = "url"
125+
}
126+
}
127+
}
128+
}
129+
130+
```
131+
132+
## Example Usage with Relations
133+
134+
```hcl
135+
136+
resource "port_blueprint" "environment" {
137+
title = "Environment"
138+
icon = "Environment"
139+
identifier = "environment"
140+
properties = {
141+
string_props = {
142+
"aws-region" = {
143+
title = "AWS Region"
144+
}
145+
"docs-url" = {
146+
title = "Docs URL"
147+
format = "url"
148+
}
149+
}
150+
}
151+
}
152+
153+
resource "port_blueprint" "microservice" {
154+
title = "Microservice"
155+
icon = "Microservice"
156+
identifier = "microservice"
157+
properties = {
158+
string_props = {
159+
"domain" = {
160+
title = "Domain"
161+
}
162+
"slack-channel" = {
163+
title = "Slack Channel"
164+
format = "url"
165+
}
166+
}
167+
}
168+
relations = {
169+
"environment" = {
170+
target = port_blueprint.environment.identifier
171+
required = true
172+
many = false
173+
}
174+
}
175+
}
176+
177+
```
178+
179+
180+
## Example Usage with Mirror Properties
181+
182+
```hcl
183+
184+
resource "port_blueprint" "microservice" {
185+
title = "Microservice"
186+
icon = "Microservice"
187+
identifier = "microservice"
188+
properties = {
189+
string_props = {
190+
"domain" = {
191+
title = "Domain"
192+
}
193+
"slack-channel" = {
194+
title = "Slack Channel"
195+
format = "url"
196+
}
197+
}
198+
}
199+
mirror_properties = {
200+
"aws-region" = {
201+
path = "environment.aws-region"
202+
}
203+
}
204+
relations = {
205+
"environment" = {
206+
target = port_blueprint.environment.identifier
207+
required = true
208+
many = false
209+
}
210+
}
211+
}
212+
213+
```
12214

13215

14216

examples/resources/port_action/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ resource "port_action" "restart_microservice" {
44
identifier = "restart-micrservice"
55
blueprint = port_blueprint.microservice.identifier
66
trigger = "DAY-2"
7-
webhook_method {
7+
webhook_method = {
88
type = "WEBHOOK"
99
url = "https://app.getport.io"
1010
}
11-
user_properties {
11+
user_properties = {
1212
string_props = {
1313
"webhook_url" = {
1414
title = "Webhook URL"

examples/resources/port_action_permissions/main.tf

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
resource "port_action_permissions" "restart_microservice_permissions_without_policy" {
2-
action_identifier = port_action.restart_microservice.identifier
2+
action_identifier = port_action.restart_microservice.identifier
33
blueprint_identifier = port_blueprint.microservice.identifier
44
permissions = {
5-
"execute": {
6-
"roles": [
5+
"execute" : {
6+
"roles" : [
77
"Admin"
88
],
9-
"users": [],
10-
"teams": [],
11-
"owned_by_team": true
9+
"users" : [],
10+
"teams" : [],
11+
"owned_by_team" : true
1212
},
13-
"approve": {
14-
"roles": ["Member", "Admin"],
15-
"users": [],
16-
"teams": []
13+
"approve" : {
14+
"roles" : ["Member", "Admin"],
15+
"users" : [],
16+
"teams" : []
1717
}
1818
}
1919
}
2020

2121
resource "port_action_permissions" "restart_microservice_permissions_with_policy" {
22-
action_identifier = port_action.restart_microservice.identifier
22+
action_identifier = port_action.restart_microservice.identifier
2323
blueprint_identifier = port_blueprint.microservice.identifier
2424
permissions = {
25-
"execute": {
26-
"roles": [
25+
"execute" : {
26+
"roles" : [
2727
"Admin"
2828
],
29-
"users": [],
30-
"teams": [],
31-
"owned_by_team": true
29+
"users" : [],
30+
"teams" : [],
31+
"owned_by_team" : true
3232
},
33-
"approve": {
34-
"roles": ["Member", "Admin"],
35-
"users": [],
36-
"teams": []
37-
"policy": jsonencode(
33+
"approve" : {
34+
"roles" : ["Member", "Admin"],
35+
"users" : [],
36+
"teams" : []
37+
"policy" : jsonencode(
3838
{
39-
queries: {
40-
executingUser: {
41-
rules: [
39+
queries : {
40+
executingUser : {
41+
rules : [
4242
{
43-
value: "user",
44-
operator: "=",
45-
property: "$blueprint"
43+
value : "user",
44+
operator : "=",
45+
property : "$blueprint"
4646
},
4747
{
48-
value: "{{.trigger.user.email}}",
49-
operator: "=",
50-
property: "$identifier"
48+
value : "{{.trigger.user.email}}",
49+
operator : "=",
50+
property : "$identifier"
5151
},
5252
{
53-
value: "true",
54-
operator: "=",
55-
property: "$owned_by_team"
53+
value : "true",
54+
operator : "=",
55+
property : "$owned_by_team"
5656

5757
}
5858
],
59-
combinator: "or"
59+
combinator : "or"
6060
}
6161
},
62-
conditions: [
63-
"true"]
62+
conditions : [
63+
"true"]
6464
}
6565
)
6666
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
resource "port_blueprint" "repository_blueprint" {
2+
title = "Repository Blueprint"
3+
icon = "Terraform"
4+
identifier = "repository"
5+
description = ""
6+
}
7+
8+
resource "port_blueprint" "pull_request_blueprint" {
9+
title = "Pull Request Blueprint"
10+
icon = "Terraform"
11+
identifier = "pull_request"
12+
description = ""
13+
properties = {
14+
string_props = {
15+
"status" = {
16+
title = "Status"
17+
}
18+
}
19+
}
20+
relations = {
21+
"repository" = {
22+
title = "Repository"
23+
target = port_blueprint.repository_blueprint.identifier
24+
}
25+
}
26+
}
27+
28+
resource "port_aggregation_property" "fix_pull_requests_per_day" {
29+
aggregation_identifier = "fix_pull_requests_count"
30+
blueprint_identifier = port_blueprint.repository_blueprint.identifier
31+
target_blueprint_identifier = port_blueprint.pull_request_blueprint.identifier
32+
title = "Pull Requests Per Day"
33+
icon = "Terraform"
34+
description = "Pull Requests Per Day"
35+
method = {
36+
average_entities = {
37+
average_of = "month"
38+
measure_time_by = "$createdAt"
39+
}
40+
}
41+
query = jsonencode(
42+
{
43+
"combinator" : "and",
44+
"rules" : [
45+
{
46+
"property" : "$title",
47+
"operator" : "ContainsAny",
48+
"value" : ["fix", "fixed", "fixing", "Fix"]
49+
}
50+
]
51+
}
52+
)
53+
}
54+

0 commit comments

Comments
 (0)