-
Notifications
You must be signed in to change notification settings - Fork 0
Dev to qa #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev to qa #105
Changes from all commits
15513f5
5e46329
f0e5b62
3e2a9fb
fbe9840
be41d07
ad52dc4
ec9845c
7758230
0fd7245
f0fa1c6
92aec94
85074fc
aa1a94f
49eeee5
12e7ef1
c8859f5
d3a7e8e
99ea2ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,6 +54,45 @@ jobs: | |||||||||||||||||||||||||
| echo "TF_VAR_google_client_secret=${{ secrets.GOOGLE_CLIENT_SECRET }}" >> $GITHUB_ENV | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Get Runner IP | ||||||||||||||||||||||||||
| id: ip | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| ip=$(curl -s https://api.ipify.org) | ||||||||||||||||||||||||||
| echo "Runner IP: $ip" | ||||||||||||||||||||||||||
| echo "TF_VAR_client_ip_address=$ip" >> $GITHUB_ENV | ||||||||||||||||||||||||||
| echo "RUNNER_IP=$ip" >> $GITHUB_ENV | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Set Key Vault Firewall to Allow | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| # Dynamic Key Vault Name Lookup | ||||||||||||||||||||||||||
| KV_NAME_PREFIX="${{ env.ENVIRONMENT }}-alpinebot-vault-" | ||||||||||||||||||||||||||
| echo "Looking for Key Vault starting with: $KV_NAME_PREFIX" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Find the Key Vault name that matches the pattern | ||||||||||||||||||||||||||
| KV_NAME=$(az keyvault list --resource-group "$RG_NAME" --query "[?starts_with(name, '$KV_NAME_PREFIX')].name | [0]" -o tsv) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [ -z "$KV_NAME" ]; then | ||||||||||||||||||||||||||
| echo "Key Vault not found. It might not be created yet." | ||||||||||||||||||||||||||
| # Fallback or exit gracefully depending on logic. | ||||||||||||||||||||||||||
| # Here we assume it's a fresh deploy and we can skip setting firewall rules for now. | ||||||||||||||||||||||||||
| echo "Skipping firewall update." | ||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Found Key Vault: $KV_NAME" | ||||||||||||||||||||||||||
| RG_NAME="${{ env.ENVIRONMENT }}-alpinebot" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Listing Key Vaults in $RG_NAME for debugging..." | ||||||||||||||||||||||||||
| az keyvault list --resource-group "$RG_NAME" --query "[].name" -o tsv || echo "Failed to list KVs" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Attempting to force Key Vault $KV_NAME firewall to Allow..." | ||||||||||||||||||||||||||
| # Try to update, ignore failure if KV doesn't exist (e.g. fresh deploy) | ||||||||||||||||||||||||||
| az keyvault update --name "$KV_NAME" --resource-group "$RG_NAME" --default-action Allow --public-network-access Enabled || echo "Key Vault update failed (it might not exist yet)." | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| echo "Waiting 60 seconds for propagation..." | ||||||||||||||||||||||||||
| sleep 60 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+92
to
97
|
||||||||||||||||||||||||||
| echo "Waiting 60 seconds for propagation..." | |
| sleep 60 | |
| echo "Waiting for Key Vault firewall rule propagation (up to 180 seconds)..." | |
| for i in {1..18}; do | |
| if az keyvault show --name "$KV_NAME" --resource-group "$RG_NAME" > /dev/null 2>&1; then | |
| echo "Key Vault is accessible after $((i*10)) seconds." | |
| break | |
| else | |
| echo "Key Vault not accessible yet, waiting 10 seconds (attempt $i/18)..." | |
| sleep 10 | |
| fi | |
| done |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] There's an extra blank line and inconsistent indentation. The environment variable TF_VAR_client_ip_address should be aligned with the other environment variables above, and there should only be one blank line between sections.
Suggested format:
TF_LOG: DEBUG
TF_LOG_PATH: terraform.log
ENVIRONMENT: ${{ env.ENVIRONMENT }}
TF_VAR_client_ip_address: ${{ env.RUNNER_IP }}| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,18 +13,35 @@ resource "azurerm_resource_group" "rg" { | |
| tags = local.environment_vars.tags | ||
| } | ||
|
|
||
| #### Create Virtual Network and Subnet ###### | ||
| module "virtual_network" { | ||
| source = "../modules/virtual_network" | ||
| vnet_name = local.environment_vars.vnet_name | ||
| az_location = local.environment_vars.az_location | ||
| az_rg_name = local.environment_vars.az_rg_name | ||
| vnet_address_space = local.environment_vars.vnet_address_space | ||
| subnet_name = local.environment_vars.subnet_name | ||
| subnet_prefix = local.environment_vars.subnet_prefix | ||
| tags = local.environment_vars.tags | ||
|
|
||
| depends_on = [azurerm_resource_group.rg] | ||
| } | ||
|
|
||
| #### Create the Azure Key Vault ##### | ||
|
|
||
| # Retrieve the runner's public IP | ||
| data "http" "ip" { | ||
| url = "https://api.ipify.org" | ||
|
|
||
|
|
||
|
|
||
| resource "random_integer" "kv_suffix" { | ||
| min = 1000 | ||
| max = 9999 | ||
| } | ||
|
|
||
| module "key_vault" { | ||
| source = "../modules/key_vault" | ||
|
|
||
| az_rg_name = local.environment_vars.az_rg_name | ||
| az_kv_name = local.environment_vars.az_kv_name | ||
| az_kv_name = "${local.environment_vars.az_kv_name}-${random_integer.kv_suffix.result}" | ||
| az_location = local.environment_vars.az_location | ||
| tenant_id = var.az_tenant_id | ||
| enabled_for_disk_encryption = false | ||
|
|
@@ -35,15 +52,16 @@ module "key_vault" { | |
|
|
||
| tags = local.environment_vars.tags | ||
|
|
||
| key_vault_ip_rules = [data.http.ip.response_body] | ||
| key_vault_ip_rules = [ | ||
| for ip in [var.client_ip_address, "83.76.0.0/14"] : ip if ip != null | ||
|
Comment on lines
+55
to
+56
|
||
| ] | ||
|
|
||
| key_vault_subnet_ids = [ | ||
| module.virtual_network.subnet_id | ||
| ] | ||
| } | ||
|
|
||
| # Wait for firewall rule propagation | ||
| resource "time_sleep" "wait_for_firewall" { | ||
| create_duration = "60s" | ||
|
|
||
| depends_on = [module.key_vault] | ||
| } | ||
|
|
||
| # Get the current service principal/client object ID | ||
| data "azurerm_client_config" "current" {} | ||
|
|
@@ -79,20 +97,23 @@ resource "azurerm_key_vault_secret" "openai_key" { | |
| depends_on = [ | ||
| module.key_vault, | ||
| module.cognitive_account, | ||
| azurerm_role_assignment.key_vault_secrets_officer, | ||
| time_sleep.wait_for_firewall | ||
| azurerm_role_assignment.key_vault_secrets_officer | ||
| ] | ||
|
Comment on lines
97
to
101
|
||
| } | ||
|
|
||
| #### Deploy AlpineBot OpenAI Account ###### | ||
| module "cognitive_account" { | ||
| source = "../modules/cognitive_account" | ||
| alpinebotaiact_name = local.environment_vars.alpinebotaiact_name | ||
| az_location = local.environment_vars.az_location | ||
| az_rg_name = local.environment_vars.az_rg_name | ||
| kind = local.environment_vars.kind | ||
| sku_name_cog_acct = local.environment_vars.sku_name_cog_acct | ||
| tags = local.environment_vars.tags | ||
| source = "../modules/cognitive_account" | ||
| alpinebotaiact_name = "${local.environment_vars.alpinebotaiact_name}-${random_integer.kv_suffix.result}" | ||
|
||
| az_location = local.environment_vars.az_location | ||
| az_rg_name = local.environment_vars.az_rg_name | ||
| kind = local.environment_vars.kind | ||
| sku_name_cog_acct = local.environment_vars.sku_name_cog_acct | ||
| tags = local.environment_vars.tags | ||
| model_deployment_name = local.environment_vars.alpinebotaidepl | ||
| model_name = local.environment_vars.model_name | ||
| model_version = local.environment_vars.model_version | ||
| deployment_sku_name = local.environment_vars.deployment_sku_name | ||
|
|
||
| depends_on = [azurerm_resource_group.rg] | ||
| } | ||
|
|
@@ -200,6 +221,7 @@ module "function_app" { | |
| az_rg_name = local.environment_vars.az_rg_name | ||
| service_plan_id = module.app_service_plan.service_plan_id | ||
| app_insights_connection_string = azurerm_application_insights.apbotinsights.connection_string | ||
| virtual_network_subnet_id = module.virtual_network.subnet_id | ||
|
|
||
| app_settings = { | ||
| "AZURE_OPENAI_API_KEY" = "@Microsoft.KeyVault(SecretUri=${azurerm_key_vault_secret.openai_key.id})" | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,14 +19,6 @@ terraform { | |||||||
| source = "cyrilgdn/postgresql" | ||||||||
| version = "1.17.0" | ||||||||
| } | ||||||||
| http = { | ||||||||
| source = "hashicorp/http" | ||||||||
| version = "~> 3.4.0" | ||||||||
| } | ||||||||
| time = { | ||||||||
| source = "hashicorp/time" | ||||||||
| version = "~> 0.9.0" | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| backend "azurerm" { | ||||||||
|
|
@@ -44,6 +36,10 @@ provider "azurerm" { | |||||||
| purge_soft_delete_on_destroy = true | ||||||||
| recover_soft_deleted_key_vaults = false | ||||||||
| } | ||||||||
| cognitive_account { | ||||||||
| purge_soft_delete_on_destroy = true | ||||||||
|
||||||||
| purge_soft_delete_on_destroy = true | |
| # Make purge_soft_delete_on_destroy configurable per environment to prevent accidental permanent deletion in production. | |
| purge_soft_delete_on_destroy = var.cognitive_account_purge_soft_delete_on_destroy |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,18 @@ resource "azurerm_cognitive_account" "alpinebot_openai" { | |
|
|
||
| tags = var.tags | ||
| } | ||
|
|
||
| resource "azurerm_cognitive_deployment" "openai_deployment" { | ||
| name = var.model_deployment_name | ||
| cognitive_account_id = azurerm_cognitive_account.alpinebot_openai.id | ||
| model { | ||
| format = "OpenAI" | ||
| name = var.model_name | ||
| version = var.model_version | ||
| } | ||
|
|
||
| sku { | ||
| name = var.deployment_sku_name | ||
| capacity = 10 | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,7 @@ resource "azurerm_key_vault" "alpinebot_kv" { | |||||
| tags = var.tags | ||||||
|
|
||||||
| network_acls { | ||||||
| default_action = "Deny" | ||||||
| default_action = "Allow" | ||||||
|
||||||
| default_action = "Allow" | |
| default_action = "Deny" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
RG_NAMEis used on line 72 before it's defined on line 83. This will cause the script to fail because the variable is referenced out of order.Move line 83 (
RG_NAME="${{ env.ENVIRONMENT }}-alpinebot") to before line 72 where it's first used, or better yet, move it to the beginning of the script after the IP retrieval.