diff --git a/src/supabase-stack.ts b/src/supabase-stack.ts index a31000e..72198e2 100644 --- a/src/supabase-stack.ts +++ b/src/supabase-stack.ts @@ -648,11 +648,17 @@ export class SupabaseStack extends FargateStack { serviceRoleKey: serviceRoleKey.ssmParameter, }); + new cdk.CfnOutput(this, 'StudioUrl', { + value: studio.prodBranchUrl, + description: 'The dashboard for Supabase projects.', + }); + new cdk.CfnOutput(this, 'SupabaseUrl', { value: apiExternalUrl, description: 'A RESTful endpoint for querying and managing your database.', exportName: `${cdk.Aws.STACK_NAME}Url`, }); + new cdk.CfnOutput(this, 'SupabasAnonKey', { value: anonKey.value, description: 'This key is safe to use in a browser if you have enabled Row Level Security for your tables and configured policies.', diff --git a/src/supabase-studio.ts b/src/supabase-studio.ts index 36f2d7d..ba365d2 100644 --- a/src/supabase-studio.ts +++ b/src/supabase-studio.ts @@ -67,8 +67,8 @@ export class SupabaseStudio extends Construct { preBuild: { commands: [ 'echo POSTGRES_PASSWORD=$(aws secretsmanager get-secret-value --secret-id $DB_SECRET_ARN --query SecretString | jq -r . | jq -r .password) >> .env.production', - 'echo SUPABASE_ANON_KEY=$(aws ssm get-parameter --region $SSM_REGION --name $ANON_KEY_NAME --query Parameter.Value) >> .env.production', - 'echo SUPABASE_SERVICE_KEY=$(aws ssm get-parameter --region $SSM_REGION --name $SERVICE_KEY_NAME --query Parameter.Value) >> .env.production', + 'echo SUPABASE_ANON_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $ANON_KEY_NAME --query Parameter.Value) >> .env.production', + 'echo SUPABASE_SERVICE_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $SERVICE_KEY_NAME --query Parameter.Value) >> .env.production', 'env | grep -e STUDIO_PG_META_URL >> .env.production', 'env | grep -e SUPABASE_ >> .env.production', 'env | grep -e NEXT_PUBLIC_ >> .env.production', @@ -124,8 +124,8 @@ export class SupabaseStudio extends Construct { STUDIO_PG_META_URL: `${supabaseUrl}/pg`, SUPABASE_URL: `${supabaseUrl}`, SUPABASE_PUBLIC_URL: `${supabaseUrl}`, + SUPABASE_REGION: serviceRoleKey.env.region, DB_SECRET_ARN: dbSecret.secretArn, - SSM_REGION: anonKey.env.region, ANON_KEY_NAME: anonKey.parameterName, SERVICE_KEY_NAME: serviceRoleKey.parameterName, }, @@ -173,8 +173,6 @@ export class SupabaseStudio extends Construct { amplifySSRLoggingPolicy.attachToRole(role); this.prodBranchUrl = `https://${this.prodBranch.branchName}.${this.app.defaultDomain}`; - - new cdk.CfnOutput(this, 'Url', { value: this.prodBranchUrl }); } } diff --git a/test/__snapshots__/main.test.ts.snap b/test/__snapshots__/main.test.ts.snap index f452efe..c2fcbff 100644 --- a/test/__snapshots__/main.test.ts.snap +++ b/test/__snapshots__/main.test.ts.snap @@ -699,7 +699,8 @@ Object { }, }, "Outputs": Object { - "StudioUrlAE70A83E": Object { + "StudioUrl": Object { + "Description": "The dashboard for Supabase projects.", "Value": Object { "Fn::Join": Array [ "", @@ -9346,8 +9347,8 @@ applications: preBuild: commands: - echo POSTGRES_PASSWORD=$(aws secretsmanager get-secret-value --secret-id $DB_SECRET_ARN --query SecretString | jq -r . | jq -r .password) >> .env.production - - echo SUPABASE_ANON_KEY=$(aws ssm get-parameter --region $SSM_REGION --name $ANON_KEY_NAME --query Parameter.Value) >> .env.production - - echo SUPABASE_SERVICE_KEY=$(aws ssm get-parameter --region $SSM_REGION --name $SERVICE_KEY_NAME --query Parameter.Value) >> .env.production + - echo SUPABASE_ANON_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $ANON_KEY_NAME --query Parameter.Value) >> .env.production + - echo SUPABASE_SERVICE_KEY=$(aws ssm get-parameter --region $SUPABASE_REGION --name $SERVICE_KEY_NAME --query Parameter.Value) >> .env.production - env | grep -e STUDIO_PG_META_URL >> .env.production - env | grep -e SUPABASE_ >> .env.production - env | grep -e NEXT_PUBLIC_ >> .env.production @@ -9476,15 +9477,15 @@ applications: }, }, Object { - "Name": "DB_SECRET_ARN", + "Name": "SUPABASE_REGION", "Value": Object { - "Ref": "DatabasedashboarduserSecret102D2F3B", + "Ref": "AWS::Region", }, }, Object { - "Name": "SSM_REGION", + "Name": "DB_SECRET_ARN", "Value": Object { - "Ref": "AWS::Region", + "Ref": "DatabasedashboarduserSecret102D2F3B", }, }, Object {