Skip to content

Commit

Permalink
create instructure_dap schema and grant canvas user create permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
cmurtaugh committed Jun 7, 2024
1 parent ef2659e commit a74bc62
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions prepare_aurora_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,36 @@
except ClientError as e:
console.print(f" ! Unexpected error creating schema {username}: {e}", style="bold red")
continue

# create the instructure_dap schema
try:
schema_sql = f"CREATE SCHEMA IF NOT EXISTS instructure_dap AUTHORIZATION {username}"
rds_data_client.execute_statement(
resourceArn=aurora_cluster_arn,
secretArn=admin_secret_arn,
sql=schema_sql,
database=database_name,
)
console.print(
f" - Created schema [bold]instructure_dap[/bold] in database [bold]{database_name}[/bold]",
style="green",
)
except ClientError as e:
console.print(f" ! Unexpected error: {e}", style="bold red")
continue

# grant create permission on database to canvas user
try:
grant_sql = f"GRANT CREATE ON DATABASE {database_name} TO {username}"
rds_data_client.execute_statement(
resourceArn=aurora_cluster_arn,
secretArn=admin_secret_arn,
sql=grant_sql,
database="postgres",
)
console.print(
f" - Granted CREATE on database {database_name} to user {username}",
style="bold green",
)
except ClientError as e:
console.print(f" ! Unexpected error: {e}", style="bold red")

0 comments on commit a74bc62

Please sign in to comment.