Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/_deploy-infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
- name: Plan Cluster Resources
id: deploy_cluster
env:
POSTGRES_ADMIN_OBJECT_ID: ${{ inputs.postgres_admin_object_id }}
GOOGLE_OAUTH_CLIENT_ID: ${{ vars.GOOGLE_OAUTH_CLIENT_ID }}
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
STRIPE_PUBLISHABLE_KEY: ${{ vars.STRIPE_PUBLISHABLE_KEY }}
Expand Down Expand Up @@ -144,6 +145,7 @@ jobs:
- name: Deploy Cluster Resources
id: deploy_cluster
env:
POSTGRES_ADMIN_OBJECT_ID: ${{ inputs.postgres_admin_object_id }}
GOOGLE_OAUTH_CLIENT_ID: ${{ vars.GOOGLE_OAUTH_CLIENT_ID }}
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
STRIPE_PUBLISHABLE_KEY: ${{ vars.STRIPE_PUBLISHABLE_KEY }}
Expand All @@ -161,9 +163,6 @@ jobs:
- name: Install PostgreSQL Client
run: sudo apt-get update && sudo apt-get install -y postgresql-client

- name: Add PostgreSQL Admin
run: bash ./cloud-infrastructure/cluster/add-postgres-admin.sh ${{ inputs.unique_prefix }} ${{ inputs.azure_environment }} ${{ inputs.cluster_location_acronym }} ${{ inputs.postgres_admin_object_id }}

- name: Open Firewall
working-directory: cloud-infrastructure/cluster
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
"tenants",
table => new
{
id = table.Column<string>("bigint", nullable: false),
id = table.Column<long>("bigint", nullable: false),
created_at = table.Column<DateTimeOffset>("timestamptz", nullable: false),
modified_at = table.Column<DateTimeOffset>("timestamptz", nullable: true),
deleted_at = table.Column<DateTimeOffset>("timestamptz", nullable: true),
Expand Down
18 changes: 0 additions & 18 deletions cloud-infrastructure/cluster/add-postgres-admin.sh

This file was deleted.

2 changes: 1 addition & 1 deletion cloud-infrastructure/cluster/deploy-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export UNIQUE_PREFIX
export ENVIRONMENT
export LOCATION=$CLUSTER_LOCATION
export DOMAIN_NAME
export POSTGRES_ADMIN_OBJECT_ID
export GOOGLE_OAUTH_CLIENT_ID
export GOOGLE_OAUTH_CLIENT_SECRET
export STRIPE_PUBLISHABLE_KEY
Expand Down Expand Up @@ -105,7 +106,6 @@ then
echo "BACK_OFFICE_IDENTITY_CLIENT_ID=$BACK_OFFICE_IDENTITY_CLIENT_ID" >> $GITHUB_OUTPUT
echo "MAIN_IDENTITY_CLIENT_ID=$MAIN_IDENTITY_CLIENT_ID" >> $GITHUB_OUTPUT
else
. ./add-postgres-admin.sh $UNIQUE_PREFIX $ENVIRONMENT $CLUSTER_LOCATION_ACRONYM $POSTGRES_ADMIN_OBJECT_ID
. ./grant-database-permissions.sh $UNIQUE_PREFIX $ENVIRONMENT $CLUSTER_LOCATION_ACRONYM 'account' $ACCOUNT_IDENTITY_CLIENT_ID
. ./grant-database-permissions.sh $UNIQUE_PREFIX $ENVIRONMENT $CLUSTER_LOCATION_ACRONYM 'back-office' $BACK_OFFICE_IDENTITY_CLIENT_ID
. ./grant-database-permissions.sh $UNIQUE_PREFIX $ENVIRONMENT $CLUSTER_LOCATION_ACRONYM 'main' $MAIN_IDENTITY_CLIENT_ID
Expand Down
5 changes: 5 additions & 0 deletions cloud-infrastructure/cluster/main-cluster.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ param communicationServicesDataLocation string = 'europe'
param mailSenderDisplayName string = 'PlatformPlatform'
param revisionSuffix string

@description('Object ID of the Entra ID security group for PostgreSQL administration')
param postgresAdminObjectId string = ''

@secure()
param googleOAuthClientId string
@secure()
Expand Down Expand Up @@ -101,6 +104,7 @@ module keyVault '../modules/key-vault.bicep' = {
subnetId: virtualNetwork.outputs.containerAppsSubnetId
storageAccountId: diagnosticStorageAccount.outputs.storageAccountId
workspaceId: existingLogAnalyticsWorkspace.id
domainName: domainName
}
}

Expand Down Expand Up @@ -153,6 +157,7 @@ module postgresServer '../modules/postgresql-flexible-server.bicep' = {
virtualNetworkId: virtualNetwork.outputs.virtualNetworkId
isProduction: environment == 'prod'
diagnosticStorageAccountId: diagnosticStorageAccount.outputs.storageAccountId
dbAdminObjectId: postgresAdminObjectId
}
}

Expand Down
1 change: 1 addition & 0 deletions cloud-infrastructure/cluster/main-cluster.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ param backOfficeVersion = readEnvironmentVariable('BACK_OFFICE_VERSION')
param mainVersion = readEnvironmentVariable('MAIN_VERSION')
param applicationInsightsConnectionString = readEnvironmentVariable('APPLICATIONINSIGHTS_CONNECTION_STRING')
param revisionSuffix = readEnvironmentVariable('REVISION_SUFFIX')
param postgresAdminObjectId = readEnvironmentVariable('POSTGRES_ADMIN_OBJECT_ID', '')
param googleOAuthClientId = readEnvironmentVariable('GOOGLE_OAUTH_CLIENT_ID', '')
param googleOAuthClientSecret = readEnvironmentVariable('GOOGLE_OAUTH_CLIENT_SECRET', '')
param stripePublishableKey = readEnvironmentVariable('STRIPE_PUBLISHABLE_KEY', '')
Expand Down
7 changes: 5 additions & 2 deletions cloud-infrastructure/modules/key-vault.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ param tenantId string
param subnetId string
param storageAccountId string
param workspaceId string
param domainName string = ''

resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' = {
name: name
Expand Down Expand Up @@ -119,19 +120,21 @@ resource authenticationTokenSigningKey 'Microsoft.KeyVault/vaults/keys@2023-07-0
}
}

var tokenIssuerAndAudience = domainName != '' ? 'https://${domainName}' : 'PlatformPlatform'

resource authenticationTokenIssuer 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = {
parent: keyVault
name: 'authentication-token-issuer'
properties: {
value: 'PlatformPlatform' // Consider using the domain name (https://app.your-company.net) or company name (Your Company) as the issuer
value: tokenIssuerAndAudience
}
}

resource authenticationTokenAudience 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = {
parent: keyVault
name: 'authentication-token-audience'
properties: {
value: 'PlatformPlatform' // Consider using the domain name (https://product.your-company.net) or product name (product-name) as the audience
value: tokenIssuerAndAudience
}
}

Expand Down
12 changes: 12 additions & 0 deletions cloud-infrastructure/modules/postgresql-flexible-server.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ param subnetId string
param virtualNetworkId string
param isProduction bool
param diagnosticStorageAccountId string
@description('Object ID of the Entra ID security group to assign as PostgreSQL administrator')
param dbAdminObjectId string = ''

resource postgresServer 'Microsoft.DBforPostgreSQL/flexibleServers@2025-08-01' = {
name: name
Expand Down Expand Up @@ -44,6 +46,16 @@ resource postgresServer 'Microsoft.DBforPostgreSQL/flexibleServers@2025-08-01' =
}
}

resource postgresServerAdministrator 'Microsoft.DBforPostgreSQL/flexibleServers/administrators@2025-08-01' = if (!empty(dbAdminObjectId)) {
parent: postgresServer
name: dbAdminObjectId
properties: {
principalName: 'PostgreSQL Admins - ${isProduction ? 'Production' : 'Staging'}'
principalType: 'Group'
tenantId: tenantId
}
}

resource privateDnsZone 'Microsoft.Network/privateDnsZones@2024-06-01' = {
name: 'privatelink.postgres.database.azure.com'
location: 'global'
Expand Down
Loading