Skip to content

This PR fixes a few minor errors in scripts - #9

Merged
paolosalvatori merged 1 commit into
mainfrom
fixes
Jun 24, 2026
Merged

This PR fixes a few minor errors in scripts#9
paolosalvatori merged 1 commit into
mainfrom
fixes

Conversation

@paolosalvatori

Copy link
Copy Markdown
Collaborator

Motivation

Addresses the GitHub Copilot review feedback on PR #8 (Azure Key Vault Provider for Secrets Store CSI Driver samples). The original scripts contained incorrect Azure CLI flags, malformed shebangs, overly permissive role assignments, missing RBAC configuration, and a missing role grant that would cause SecretProviderClass mounts to fail with authorization errors.

Changes

  • samples/web-app-postgresql-flexible-server/scripts/01-deploy-resources.sh: corrected az postgres flexible-server flags to match the MySQL sample — firewall-rule create now uses --name/--rule-name, and db show/db create use --database-name.
  • Fixed malformed shebangs (#/bin/bash#!/bin/bash) in six CSI driver scripts: 03-create-managed-identity.sh, 04-create-secret-provider-class.sh, 05-create-demo-pod.sh (workload-identity) and 03-create-role-assignment.sh, 04-create-secret-provider-class.sh, 05-create-demo-pod.sh (user-assigned-managed-identity).
  • Added --enable-rbac-authorization true to both 02-create-key-vault-and-secrets.sh scripts so subsequent RBAC role assignments grant data-plane access.
  • Replaced Key Vault Administrator with the least-privilege Key Vault Secrets User role in user-assigned-managed-identity/03-create-role-assignment.sh and workload-identity/03-create-managed-identity.sh, corrected the misleading "node resource group" comments, and removed the redundant PRINCIPAL_ID="$PRINCIPAL_ID" assignment.
  • Added validation of AKS_OIDC_ISSUER_URL in workload-identity/03-create-managed-identity.sh to fail early with an actionable message when the OIDC issuer is not enabled.
  • Removed --stdin --tty from kubectl exec and quoted variables/paths in both 06-list-secrets.sh scripts so they run in non-interactive/CI shells.
  • scripts/01-user-assigned-managed-identity.sh: added a role assignment step granting the azureKeyvaultSecretsProvider add-on managed identity the Key Vault Secrets User role on $key_vault_id, mirroring the system-assigned script.

Copilot AI review requested due to automatic review settings June 24, 2026 15:26
@paolosalvatori
paolosalvatori merged commit 893d910 into main Jun 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates several Bash scripts across the AKS samples to correct Azure CLI flag usage, fix script execution issues, and tighten/complete Key Vault RBAC configuration so the Key Vault CSI driver samples work reliably (including in non-interactive/CI environments).

Changes:

  • Fixes Azure CLI flag usage for PostgreSQL flexible server firewall rules and database commands.
  • Fixes malformed shebangs and improves non-interactive kubectl exec usage/quoting in CSI driver sample scripts.
  • Enables Key Vault RBAC authorization and updates role assignments toward least-privilege access; adds a missing role assignment step for the Key Vault Secrets Provider add-on identity.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/01-user-assigned-managed-identity.sh Adds role assignment for the Key Vault Secrets Provider add-on identity (but currently grants an overly privileged role and has incorrect exit codes in new error paths).
samples/web-app-postgresql-flexible-server/scripts/01-deploy-resources.sh Corrects az postgres flexible-server flags to match the MySQL sample and current CLI expectations.
samples/key-vault-csi-driver/workload-identity/02-create-key-vault-and-secrets.sh Enables RBAC authorization on Key Vault creation for RBAC-based data-plane access.
samples/key-vault-csi-driver/workload-identity/03-create-managed-identity.sh Fixes shebang, switches to least-privilege Key Vault role, and fails early if OIDC issuer URL is missing.
samples/key-vault-csi-driver/workload-identity/04-create-secret-provider-class.sh Fixes malformed shebang.
samples/key-vault-csi-driver/workload-identity/05-create-demo-pod.sh Fixes malformed shebang.
samples/key-vault-csi-driver/workload-identity/06-list-secrets.sh Removes interactive kubectl exec flags and improves quoting for CI/non-interactive shells.
samples/key-vault-csi-driver/user-assigned-managed-identity/02-create-key-vault-and-secrets.sh Enables RBAC authorization on Key Vault creation for RBAC-based data-plane access.
samples/key-vault-csi-driver/user-assigned-managed-identity/03-create-role-assignment.sh Fixes shebang and updates role assignment to least-privilege Key Vault role.
samples/key-vault-csi-driver/user-assigned-managed-identity/04-create-secret-provider-class.sh Fixes malformed shebang.
samples/key-vault-csi-driver/user-assigned-managed-identity/05-create-demo-pod.sh Fixes malformed shebang.
samples/key-vault-csi-driver/user-assigned-managed-identity/06-list-secrets.sh Removes interactive kubectl exec flags and improves quoting for CI/non-interactive shells.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

echo "Successfully retrieved the objectId for the Azure Key Vault Secrets Provider identity in the [$aks_cluster_name] AKS cluster"
else
echo "Failed to retrieve the objectId for the Azure Key Vault Secrets Provider identity in the [$aks_cluster_name] AKS cluster"
exit
echo "Successfully retrieved the resourceId for the Azure Key Vault Secrets Provider identity in the [$aks_cluster_name] AKS cluster"
else
echo "Failed to retrieve the resourceId for the Azure Key Vault Secrets Provider identity in the [$aks_cluster_name] AKS cluster"
exit
Comment on lines +783 to +787
kv_secret_provider_managed_identity_name=$(basename $kv_secret_provider_managed_identity_resource_id)

# Assign the Key Vault Administrator role to the managed identity on the node resource group
role="Key Vault Administrator"
managed_identity_name="$kv_secret_provider_managed_identity_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants