-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathms-teams-drift-detection-with-changes.rego
More file actions
56 lines (51 loc) · 1.55 KB
/
ms-teams-drift-detection-with-changes.rego
File metadata and controls
56 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package spacelift
webhook[wbdata] {
# 1. Identify the specific webhook
endpoint := input.webhook_endpoints[_]
endpoint.id == "teams-webhook" # Change this to your webhook ID
# 2. Logic: Only trigger if drift is detected and there are changes
input.run_updated.run.drift_detection
count(input.run_updated.run.changes) > 0
# 3. Helpers for readability
stack := input.run_updated.stack
run := input.run_updated.run
# 4. Construct the payload
wbdata := {
"endpoint_id": endpoint.id,
"payload": {
"type": "message",
"attachments": [{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"size": "Large",
"weight": "Bolder",
"text": "🔄 Drift Detected",
"wrap": true,
},
{
"type": "FactSet",
"facts": [
{"title": "Stack", "value": stack.name},
{"title": "State", "value": run.state},
{"title": "Changes", "value": sprintf("%d resource(s)", [count(run.changes)])},
],
},
],
"actions": [{
"type": "Action.OpenUrl",
"title": "View in Spacelift",
# change your URL below to app.us.spacelift.io if you are using the US region or app.eu.spacelift.io if you are using the EU region
"url": sprintf("https://%s.app.spacelift.io/stack/%s/run/%s", [input.account.name, stack.id, run.id]),
}],
},
}],
},
}
}
sample := true