Skip to content

Commit 8ea55f0

Browse files
committed
Updated Actions Workflow
1 parent ada7a86 commit 8ea55f0

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

.github/workflows/deploy-azure.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ jobs:
4242
terraform plan -var="environment=${{ env.ENVIRONMENT }}" \
4343
-var="memgraph_username=${{ secrets.MEMGRAPH_USERNAME }}" \
4444
-var="memgraph_password=${{ secrets.MEMGRAPH_PASSWORD }}" \
45-
-var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}"
45+
-var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}" \
46+
-var="tenant_id=${{ secrets.AZURE_TENANT_ID }}" \
47+
-var="object_id=${{ secrets.AZURE_SP_OBJECT_ID }}"
4648
4749
- name: Terraform Apply
4850
run: |
@@ -51,7 +53,9 @@ jobs:
5153
-var="environment=${{ env.ENVIRONMENT }}" \
5254
-var="memgraph_username=${{ secrets.MEMGRAPH_USERNAME }}" \
5355
-var="memgraph_password=${{ secrets.MEMGRAPH_PASSWORD }}" \
54-
-var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}"
56+
-var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}" \
57+
-var="tenant_id=${{ secrets.AZURE_TENANT_ID }}" \
58+
-var="object_id=${{ secrets.AZURE_SP_OBJECT_ID }}"
5559
5660
- name: Get AKS Credentials
5761
run: |

infra/azure/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ resource "azurerm_key_vault" "ai_agent" {
1717
sku_name = "standard"
1818

1919
purge_protection_enabled = true
20+
21+
access_policy {
22+
tenant_id = var.tenant_id
23+
object_id = var.object_id
24+
25+
secret_permissions = [
26+
"get",
27+
"list",
28+
"set",
29+
]
30+
}
2031
}
2132

2233
# Add secrets to Key Vault

infra/azure/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ variable "memgraph_password" {
1919
variable "subscription_id" {
2020
description = "The Azure subscription ID"
2121
type = string
22+
}
23+
24+
variable "tenant_id" {
25+
description = "The Azure tenant ID"
26+
type = string
27+
}
28+
29+
variable "object_id" {
30+
description = "The object ID of the service principal"
31+
type = string
2232
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/zsh
2+
3+
# This script gets the object ID of a service principal by its display name or app ID
4+
# Usage: ./get_service_principal_objectid.sh <service-principal-name-or-id>
5+
6+
# Check if required parameter is provided
7+
if [ $# -lt 1 ]; then
8+
echo "Error: Missing required parameter."
9+
echo "Usage: $0 <service-principal-name-or-id>"
10+
echo ""
11+
echo "Provide either the display name or app ID of your service principal."
12+
echo "You can list all service principals with: az ad sp list --all --query \"[].{name:displayName, appId:appId}\" -o table"
13+
exit 1
14+
fi
15+
16+
SP_IDENTIFIER="ai-agent-github"
17+
18+
# First try finding by display name
19+
echo "Searching for service principal with display name '$SP_IDENTIFIER'..."
20+
OBJECT_ID=$(az ad sp list --display-name "$SP_IDENTIFIER" --query "[0].id" -o tsv)
21+
22+
# If not found by display name, try as an app ID
23+
if [ -z "$OBJECT_ID" ]; then
24+
echo "Not found by display name, trying as app ID..."
25+
OBJECT_ID=$(az ad sp show --id "$SP_IDENTIFIER" --query "id" -o tsv 2>/dev/null)
26+
fi
27+
28+
if [ -z "$OBJECT_ID" ]; then
29+
echo "No service principal found with the provided identifier."
30+
echo "List all service principals with: az ad sp list --all --query \"[].{name:displayName, appId:appId}\" -o table"
31+
exit 1
32+
else
33+
echo "Service Principal Object ID: $OBJECT_ID"
34+
echo ""
35+
echo "You can use this Object ID in your Terraform variables or Azure Key Vault access policies."
36+
echo "For Terraform, add it to your variables file as: object_id = \"$OBJECT_ID\""
37+
fi

0 commit comments

Comments
 (0)