Skip to content

Commit

Permalink
More fixes to the Bicep
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelafox committed Apr 16, 2024
1 parent d29b1ea commit ef9bb67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion infra/core/database/postgresql/flexibleserver.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ resource addAddUser 'Microsoft.DBforPostgreSQL/flexibleServers/administrators@20
principalName: entraAdministratorName
}
// This is a workaround for a bug in the API that requires the parent to be fully resolved
dependsOn: [postgresServer]
dependsOn: [postgresServer, firewall_all, firewall_azure]
}

output POSTGRES_DOMAIN_NAME string = postgresServer.properties.fullyQualifiedDomainName
6 changes: 3 additions & 3 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
}
}

var webAppName = '${prefix}-app-service'
var webAppName = '${prefix}-appservice'
module web 'core/host/appservice.bicep' = {
name: 'appservice'
scope: resourceGroup
params: {
name: '${prefix}-appservice'
name: webAppName
location: location
tags: union(tags, { 'azd-service-name': 'web' })
appServicePlanId: appServicePlan.outputs.id
Expand Down Expand Up @@ -96,7 +96,7 @@ module appServicePlan 'core/host/appserviceplan.bicep' = {
location: location
tags: tags
sku: {
name: 'F1'
name: 'B1'
}
reserved: true
}
Expand Down
13 changes: 7 additions & 6 deletions scripts/assign_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def assign_role_for_webapp(postgres_host, postgres_username, app_identity_name):
else:
logger.info(f"Creating a PostgreSQL role for identity {app_identity_name}")
cur.execute(f"SELECT * FROM pgaadauth_create_principal('{app_identity_name}', false, false)")
cur.execute(f'GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "{app_identity_name}"')
cur.execute(
f"ALTER DEFAULT PRIVILEGES IN SCHEMA public"
f'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLES TO "{app_identity_name}"'
)
logger.info(f"Granting permissions to {app_identity_name}")
cur.execute(f'GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO "{app_identity_name}"')
cur.execute(
f"ALTER DEFAULT PRIVILEGES IN SCHEMA public "
f'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLES TO "{app_identity_name}"'
)
cur.close()


Expand All @@ -52,7 +53,7 @@ def assign_role_for_webapp(postgres_host, postgres_username, app_identity_name):
APP_IDENTITY_NAME = os.getenv("WEB_APP_NAME")
if not POSTGRES_HOST or not POSTGRES_USERNAME or not APP_IDENTITY_NAME:
logger.error(
"Can't find POSTGRES_DOMAIN_NAME, POSTGRES_ADMIN_USERNAME, and WEB_APP_NAME environment variables."
"Can't find POSTGRES_DOMAIN_NAME, POSTGRES_ADMIN_USERNAME, and WEB_APP_NAME environment variables. "
"Make sure you run azd up first."
)
else:
Expand Down

0 comments on commit ef9bb67

Please sign in to comment.