Skip to content

Commit 4df4d5b

Browse files
committed
Fix App Insights API version, retention parity, bootstrap auth, budget validation
- Revert App Insights API to 2020-02-02 (2020-11-20 does not exist) - Fix App Insights RetentionInDays 90->30 to match TF parity - Add Azure auth check to bootstrap-backend.sh - Add UUID validation to management group subscription ID variables - Add @minValue(1) to monthlyBudgetAmount in Bicep - Add @minlength(1) to budgetAlertEmails in Bicep
1 parent 8c8fa1f commit 4df4d5b

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

examples/api-first-startup/main.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ resource law 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
4747
}
4848
}
4949

50-
resource appInsights 'Microsoft.Insights/components@2020-11-20' = {
50+
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
5151
name: 'ai-${appName}-${environment}'
5252
location: location
5353
tags: tags
5454
kind: 'web'
5555
properties: {
5656
Application_Type: 'web'
5757
WorkspaceResourceId: law.id
58-
RetentionInDays: 90
58+
RetentionInDays: 30
5959
}
6060
}
6161

infra/bicep/main.bicep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ param companyName string
1818
param environment string
1919

2020
@description('Monthly budget amount in USD')
21+
@minValue(1)
2122
param monthlyBudgetAmount int
2223

2324
@description('Email addresses for budget alerts')
25+
@minLength(1)
2426
param budgetAlertEmails array
2527

2628
@description('Deploy VNet and networking resources')

infra/terraform/modules/management-groups/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ variable "display_name" {
1010
variable "prod_subscription_id" {
1111
description = "Production subscription ID to place under this management group"
1212
type = string
13+
validation {
14+
condition = can(regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.prod_subscription_id))
15+
error_message = "prod_subscription_id must be a valid UUID."
16+
}
1317
}
1418
variable "nonprod_subscription_id" {
1519
description = "Non-production subscription ID to place under this management group"
1620
type = string
21+
validation {
22+
condition = can(regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.nonprod_subscription_id))
23+
error_message = "nonprod_subscription_id must be a valid UUID."
24+
}
1725
}

scripts/bootstrap-backend.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ if ! [[ "$STORAGE_ACCOUNT" =~ ^[a-z0-9]{3,24}$ ]]; then
5555
exit 1
5656
fi
5757

58+
# Verify Azure CLI authentication
59+
if ! az account show &>/dev/null; then
60+
echo "Error: Not logged in to Azure. Run: az login"
61+
exit 1
62+
fi
63+
5864
echo "=== Bootstrapping Terraform Backend ==="
5965
echo " Location: $LOCATION"
6066
echo " Resource Group: $RESOURCE_GROUP"

0 commit comments

Comments
 (0)