Skip to content

Commit 6bfd8e5

Browse files
committed
Enable pgaadauth extension, add Private DNS dependsOn, fix firewall CLI syntax, and fail on SQL errors
1 parent d340d87 commit 6bfd8e5

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

cloud-infrastructure/cluster/firewall.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ FIREWALL_RULE_NAME="github-action-${DATABASE_NAME}"
44
if [[ "$1" == "open" ]]
55
then
66
echo "$(date +"%Y-%m-%dT%H:%M:%S") Add the IP $IP_ADDRESS to the PostgreSQL server firewall on server $POSTGRES_SERVER_NAME for database $DATABASE_NAME"
7-
az postgres flexible-server firewall-rule create --resource-group $CLUSTER_RESOURCE_GROUP_NAME --server-name $POSTGRES_SERVER_NAME --name "$FIREWALL_RULE_NAME" --start-ip-address $IP_ADDRESS --end-ip-address $IP_ADDRESS
7+
az postgres flexible-server firewall-rule create --resource-group $CLUSTER_RESOURCE_GROUP_NAME --name $POSTGRES_SERVER_NAME --rule-name "$FIREWALL_RULE_NAME" --start-ip-address $IP_ADDRESS --end-ip-address $IP_ADDRESS
88
else
99
echo "$(date +"%Y-%m-%dT%H:%M:%S") Delete the IP $IP_ADDRESS from the PostgreSQL server firewall on server $POSTGRES_SERVER_NAME for database $DATABASE_NAME"
10-
az postgres flexible-server firewall-rule delete --resource-group $CLUSTER_RESOURCE_GROUP_NAME --server-name $POSTGRES_SERVER_NAME --name "$FIREWALL_RULE_NAME" --yes
10+
az postgres flexible-server firewall-rule delete --resource-group $CLUSTER_RESOURCE_GROUP_NAME --name $POSTGRES_SERVER_NAME --rule-name "$FIREWALL_RULE_NAME" --yes
1111
fi

cloud-infrastructure/cluster/grant-database-permissions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ echo "$(date +"%Y-%m-%dT%H:%M:%S") Granting $MANAGED_IDENTITY_NAME (Client ID: $
2525
# and grant it the necessary permissions. The pgaadauth_create_principal function handles
2626
# Entra ID principal creation in Azure Database for PostgreSQL Flexible Server.
2727
ENTRA_USER=$(az postgres flexible-server microsoft-entra-admin list --resource-group $CLUSTER_RESOURCE_GROUP_NAME --server-name $POSTGRES_SERVER_NAME --query "[0].principalName" --output tsv)
28-
PGPASSWORD=$ACCESS_TOKEN psql "host=$POSTGRES_HOST dbname=$DATABASE_NAME user='$ENTRA_USER' sslmode=require" << EOF
28+
PGPASSWORD=$ACCESS_TOKEN psql -v ON_ERROR_STOP=1 "host=$POSTGRES_HOST dbname=$DATABASE_NAME user='$ENTRA_USER' sslmode=require" << EOF
2929
DO \$\$
3030
BEGIN
3131
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = '$MANAGED_IDENTITY_NAME') THEN

cloud-infrastructure/modules/postgresql-flexible-server.bicep

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ resource privateDnsZoneVnetLink 'Microsoft.Network/privateDnsZones/virtualNetwor
5656
}
5757

5858
resource privateEndpoint 'Microsoft.Network/privateEndpoints@2025-01-01' = {
59-
name: '${name}-postgres-private-endpoint'
59+
name: '${name}-postgres'
6060
location: location
6161
tags: tags
6262
properties: {
63+
customNetworkInterfaceName: '${name}-postgres'
6364
subnet: {
6465
id: subnetId
6566
}

0 commit comments

Comments
 (0)