Skip to content

Commit cecacb3

Browse files
Merge pull request #138 from Rafi-Microsoft/fix/vm-credential-security
fix: Remove hardcoded VM admin password and improve credential security
2 parents c4afafd + fd99705 commit cecacb3

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

docs/deploymentguide.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,10 @@ For network-isolated deployments, set the VM credentials before running `azd up`
245245

246246
```powershell
247247
azd env set VM_ADMIN_USERNAME "youradminuser"
248-
azd env set VM_ADMIN_PASSWORD "Use-A-Strong-Password-Here!"
248+
azd env set VM_ADMIN_PASSWORD "<your-strong-password>"
249249
```
250250

251-
If you prefer source-controlled defaults, set them in [infra/main.bicepparam](../infra/main.bicepparam) instead:
252-
253-
```bicep
254-
param vmUserName = 'youradminuser'
255-
param vmAdminPassword = 'Use-A-Strong-Password-Here!'
256-
```
251+
> ⚠️ **Security Warning:** Do **not** commit VM passwords to source control. Always use `azd env set`, a secrets manager, or pipeline secret variables for sensitive credentials. The `infra/main.bicepparam` file reads the password from the `VM_ADMIN_PASSWORD` environment variable at deployment time — no default is provided intentionally, so deployment will prompt or fail if the variable is unset.
257252
258253
</details>
259254

infra/main.bicepparam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ param containerAppsList = [
205205
]
206206

207207
param vmUserName = readEnvironmentVariable('VM_ADMIN_USERNAME', 'testvmuser')
208-
param vmAdminPassword = readEnvironmentVariable('VM_ADMIN_PASSWORD', 'JumpboxAdminP@ssw0rd1234!')
208+
param vmAdminPassword = readEnvironmentVariable('VM_ADMIN_PASSWORD', '')
209209
param vmSize = 'Standard_D2s_v4'
210210

211211
// ========================================

scripts/quota_check.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ MODEL_COUNT=${#MODEL_NAMES[@]}
180180

181181
# ---- Results tracking ----
182182
declare -A REGION_STATUS
183+
declare -A RESULTS
183184
VALID_REGIONS=()
184185

185186
# ---- Main quota check loop ----
@@ -213,7 +214,7 @@ for REGION in "${REGIONS[@]}"; do
213214
echo " (Looked for: $primary_key${alt_key:+, $alt_key})"
214215
fi
215216
ALL_PASS=false
216-
eval "RESULT_${safe_region}_${i}=N_A"
217+
RESULTS["${safe_region}:${i}"]="N_A"
217218
continue
218219
fi
219220

@@ -223,7 +224,7 @@ for REGION in "${REGIONS[@]}"; do
223224
LIMIT=${LIMIT%%.*}
224225
AVAILABLE=$((LIMIT - CURRENT))
225226

226-
eval "RESULT_${safe_region}_${i}=${AVAILABLE}_${LIMIT}"
227+
RESULTS["${safe_region}:${i}"]="${AVAILABLE}_${LIMIT}"
227228

228229
if [[ "$AVAILABLE" -lt "$mcap" ]]; then
229230
echo "$display | Used: $CURRENT | Limit: $LIMIT | Available: $AVAILABLE | Need: $mcap"
@@ -291,7 +292,7 @@ for REGION in "${REGIONS[@]}"; do
291292

292293
for ((i=0; i<MODEL_COUNT; i++)); do
293294
mcap="${MODEL_CAPS[$i]}"
294-
eval "val=\${RESULT_${safe_region}_${i}:-N_A}"
295+
val="${RESULTS["${safe_region}:${i}"]:-N_A}"
295296

296297
if [[ "$val" == "N_A" ]]; then
297298
printf "%-30s" "⚠️ N/A"

0 commit comments

Comments
 (0)