Skip to content

Commit

Permalink
Merge pull request #55 from supabase-community/refactor-cfn-parameter
Browse files Browse the repository at this point in the history
chore: refactoring
  • Loading branch information
mats16 authored Jul 5, 2023
2 parents 97c37f7 + b57fce5 commit cb08930
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/supabase-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
8 changes: 3 additions & 5 deletions src/supabase-studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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 });
}

}
Expand Down
15 changes: 8 additions & 7 deletions test/__snapshots__/main.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cb08930

Please sign in to comment.