supabase-community/supabase-on-aws

`cdk deploy Supabase` fails

sagacity-felix opened this issue · 2 comments

Bug report

First of all, thanks for fixing the git issue in the Repository import.

When I try to deploy this stack after cloning it, it still fails due to one of two reasons.

Describe the bug

  1. Sometimes, the RepoImportJob exceeds the timelimit and I get:
12:46:52 PM | CREATE_FAILED        | Custom::RepoImportJob                         | Studio/Repo/main/Default
Received response status [FAILED] from custom resource. Message returned: Error: 2023-03-30T10:46:42.596Z 502e30ef-ab43-4586-be80-dc3fb00eb348 Task timed out afte
r 180.00 seconds

Logs: /aws/lambda/Supabase-StudioRepoImportFunctionDEF0C9F1-gLGfGN4WUBfy

at invokeUserFunction (/var/task/framework.js:2:6)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async onEvent (/var/task/framework.js:1:365)
at async Runtime.handler (/var/task/cfn-response.js:1:1543) (RequestId: 6ee1ee56-3131-4f79-b55d-b179a39a52ea)
  1. Other times (I think if I increase the timeout of the RepoImportJob to 5min instead of 3min), I get the following issue with the Auth/Fargate/Service resource (also see screenshot):
Resource handler returned message: "Error occurred during operation 'ECS Deployment Circuit Breaker was triggered'." (RequestToken: xxx-xxx-xxx-xxx, HandlerErrorCode: GeneralServiceException)

In the ECS view in the AWS console, it just tells me that the service is unhealthy.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Clone the repository
  2. Run cdk deploy Supabase (after signing in with the CLI)
  3. It will successfully create almost all the resources but then fails as mentioned above

Expected behavior

The stack should be successfully created

Screenshots

image

System information

  • OS: macOS
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

Add any other context about the problem here.

I did some more digging and it seems that the problem stems from the DB not being accessible correctly.

Here is what I get in the ECS logs for this Fargate service:

{"level":"fatal","msg":"running db migrations: Migrator: problem creating schema migrations: couldn't start a new transaction: could not create new transaction: failed to connect to `host=supabase-databaseclusterXXXXX-XXXXXX.cluster-XXXXX.eu-central-1.rds.amazonaws.com user=supabase_admin database=postgres`: failed SASL auth (FATAL: password authentication failed for user \"supabase_admin\" (SQLSTATE 28P01))","time":"2023-03-30T13:02:47Z"}

Seems to be a duplicate of #12. @mats16 feel free to close it if that is the case