Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces rate-limit, stripe-billing and usage-estimator with commerce #6540

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 6 additions & 31 deletions deployment/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as pulumi from '@pulumi/pulumi';
import { deployApp } from './services/app';
import { deployStripeBilling } from './services/billing';
import { deployCFBroker } from './services/cf-broker';
import { deployCFCDN } from './services/cf-cdn';
import { deployClickhouse } from './services/clickhouse';
import { deployCloudFlareSecurityTransform } from './services/cloudflare-security';
import { deployCommerce } from './services/commerce';
import { deployDatabaseCleanupJob } from './services/database-cleanup';
import { deployDbMigrations } from './services/db-migrations';
import { configureDocker } from './services/docker';
Expand All @@ -17,7 +17,6 @@ import { deployObservability } from './services/observability';
import { deploySchemaPolicy } from './services/policy';
import { deployPostgres } from './services/postgres';
import { deployProxy } from './services/proxy';
import { deployRateLimit } from './services/rate-limit';
import { deployRedis } from './services/redis';
import { deployS3, deployS3AuditLog, deployS3Mirror } from './services/s3';
import { deploySchema } from './services/schema';
Expand All @@ -27,7 +26,6 @@ import { configureSlackApp } from './services/slack-app';
import { deploySuperTokens } from './services/supertokens';
import { deployTokens } from './services/tokens';
import { deployUsage } from './services/usage';
import { deployUsageEstimation } from './services/usage-estimation';
import { deployUsageIngestor } from './services/usage-ingestor';
import { deployWebhooks } from './services/webhooks';
import { configureZendesk } from './services/zendesk';
Expand Down Expand Up @@ -148,37 +146,16 @@ const emails = deployEmails({
observability,
});

const usageEstimator = deployUsageEstimation({
image: docker.factory.getImageId('usage-estimator', imagesTag),
const commerce = deployCommerce({
image: docker.factory.getImageId('commerce', imagesTag),
docker,
environment,
clickhouse,
dbMigrations,
sentry,
observability,
});

const billing = deployStripeBilling({
image: docker.factory.getImageId('stripe-billing', imagesTag),
docker,
postgres,
environment,
dbMigrations,
usageEstimator,
sentry,
observability,
});

const rateLimit = deployRateLimit({
image: docker.factory.getImageId('rate-limit', imagesTag),
docker,
environment,
dbMigrations,
usageEstimator,
emails,
postgres,
sentry,
observability,
});

const usage = deployUsage({
Expand All @@ -188,7 +165,7 @@ const usage = deployUsage({
tokens,
kafka,
dbMigrations,
rateLimit,
commerce,
sentry,
observability,
});
Expand Down Expand Up @@ -241,9 +218,7 @@ const graphql = deployGraphQL({
redis,
usage,
cdn,
usageEstimator,
rateLimit,
billing,
commerce,
emails,
supertokens,
s3,
Expand Down Expand Up @@ -302,7 +277,7 @@ const app = deployApp({
image: docker.factory.getImageId('app', imagesTag),
docker,
zendesk,
billing,
commerce,
github: githubApp,
slackApp,
sentry,
Expand Down
8 changes: 4 additions & 4 deletions deployment/services/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { randomUUID } from 'crypto';
import * as pulumi from '@pulumi/pulumi';
import { serviceLocalEndpoint } from '../utils/local-endpoint';
import { ServiceDeployment } from '../utils/service-deployment';
import { StripeBilling } from './billing';
import { CommerceService } from './commerce';
import { DbMigrations } from './db-migrations';
import { Docker } from './docker';
import { Environment } from './environment';
Expand All @@ -23,7 +23,7 @@ export function deployApp({
zendesk,
github,
slackApp,
billing,
commerce,
sentry,
environment,
}: {
Expand All @@ -35,7 +35,7 @@ export function deployApp({
zendesk: Zendesk;
github: GitHubApp;
slackApp: SlackApp;
billing: StripeBilling;
commerce: CommerceService;
sentry: Sentry;
publishAppDeploymentCommand: pulumi.Resource | undefined;
}) {
Expand Down Expand Up @@ -79,7 +79,7 @@ export function deployApp({
)
.withSecret('INTEGRATION_SLACK_CLIENT_ID', slackApp.secret, 'clientId')
.withSecret('INTEGRATION_SLACK_CLIENT_SECRET', slackApp.secret, 'clientSecret')
.withSecret('STRIPE_PUBLIC_KEY', billing.secret, 'stripePublicKey')
.withSecret('STRIPE_PUBLIC_KEY', commerce.stripeSecret, 'stripePublicKey')
.withConditionalSecret(sentry.enabled, 'SENTRY_DSN', sentry.secret, 'dsn')
.deploy();
}
30 changes: 19 additions & 11 deletions deployment/services/billing.ts → deployment/services/commerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,41 @@ import * as pulumi from '@pulumi/pulumi';
import { serviceLocalEndpoint } from '../utils/local-endpoint';
import { ServiceSecret } from '../utils/secrets';
import { ServiceDeployment } from '../utils/service-deployment';
import { Clickhouse } from './clickhouse';
import { DbMigrations } from './db-migrations';
import { Docker } from './docker';
import { Emails } from './emails';
import { Environment } from './environment';
import { Observability } from './observability';
import { Postgres } from './postgres';
import { Sentry } from './sentry';
import { UsageEstimator } from './usage-estimation';

export type StripeBillingService = ReturnType<typeof deployStripeBilling>;
export type CommerceService = ReturnType<typeof deployCommerce>;

class StripeSecret extends ServiceSecret<{
stripePrivateKey: pulumi.Output<string> | string;
stripePublicKey: string | pulumi.Output<string>;
}> {}

export function deployStripeBilling({
export function deployCommerce({
observability,
environment,
dbMigrations,
usageEstimator,
emails,
image,
docker,
postgres,
clickhouse,
sentry,
}: {
observability: Observability;
usageEstimator: UsageEstimator;
image: string;
environment: Environment;
dbMigrations: DbMigrations;
docker: Docker;
emails: Emails;
postgres: Postgres;
clickhouse: Clickhouse;
sentry: Sentry;
}) {
const billingConfig = new pulumi.Config('billing');
Expand All @@ -42,7 +45,7 @@ export function deployStripeBilling({
stripePublicKey: billingConfig.require('stripePublicKey'),
});
const { deployment, service } = new ServiceDeployment(
'stripe-billing',
'commerce',
{
image,
imagePullSecret: docker.secret,
Expand All @@ -53,7 +56,9 @@ export function deployStripeBilling({
env: {
...environment.envVars,
SENTRY: sentry.enabled ? '1' : '0',
USAGE_ESTIMATOR_ENDPOINT: serviceLocalEndpoint(usageEstimator.service),
EMAILS_ENDPOINT: serviceLocalEndpoint(emails.service),
WEB_APP_URL: `https://${environment.appDns}/`,
OPENTELEMETRY_TRACE_USAGE_REQUESTS: observability.enabledForUsageService ? '1' : '',
OPENTELEMETRY_COLLECTOR_ENDPOINT:
observability.enabled && observability.tracingEndpoint
? observability.tracingEndpoint
Expand All @@ -62,7 +67,7 @@ export function deployStripeBilling({
exposesMetrics: true,
port: 4000,
},
[dbMigrations, usageEstimator.service, usageEstimator.deployment],
[dbMigrations],
)
.withSecret('STRIPE_SECRET_KEY', stripeSecret, 'stripePrivateKey')
.withSecret('POSTGRES_HOST', postgres.pgBouncerSecret, 'host')
Expand All @@ -71,14 +76,17 @@ export function deployStripeBilling({
.withSecret('POSTGRES_PASSWORD', postgres.pgBouncerSecret, 'password')
.withSecret('POSTGRES_DB', postgres.pgBouncerSecret, 'database')
.withSecret('POSTGRES_SSL', postgres.pgBouncerSecret, 'ssl')
.withSecret('CLICKHOUSE_HOST', clickhouse.secret, 'host')
.withSecret('CLICKHOUSE_PORT', clickhouse.secret, 'port')
.withSecret('CLICKHOUSE_USERNAME', clickhouse.secret, 'username')
.withSecret('CLICKHOUSE_PASSWORD', clickhouse.secret, 'password')
.withSecret('CLICKHOUSE_PROTOCOL', clickhouse.secret, 'protocol')
.withConditionalSecret(sentry.enabled, 'SENTRY_DSN', sentry.secret, 'dsn')
.deploy();

return {
deployment,
service,
secret: stripeSecret,
stripeSecret,
};
}

export type StripeBilling = ReturnType<typeof deployStripeBilling>;
20 changes: 6 additions & 14 deletions deployment/services/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as pulumi from '@pulumi/pulumi';
import { serviceLocalEndpoint } from '../utils/local-endpoint';
import { ServiceSecret } from '../utils/secrets';
import { ServiceDeployment } from '../utils/service-deployment';
import { StripeBillingService } from './billing';
import { CDN } from './cf-cdn';
import { Clickhouse } from './clickhouse';
import { CommerceService } from './commerce';
import { DbMigrations } from './db-migrations';
import { Docker } from './docker';
import { Emails } from './emails';
Expand All @@ -13,15 +13,13 @@ import { GitHubApp } from './github';
import { Observability } from './observability';
import { SchemaPolicy } from './policy';
import { Postgres } from './postgres';
import { RateLimitService } from './rate-limit';
import { Redis } from './redis';
import { S3 } from './s3';
import { Schema } from './schema';
import { Sentry } from './sentry';
import { Supertokens } from './supertokens';
import { Tokens } from './tokens';
import { Usage } from './usage';
import { UsageEstimator } from './usage-estimation';
import { Webhooks } from './webhooks';
import { Zendesk } from './zendesk';

Expand All @@ -43,10 +41,8 @@ export function deployGraphQL({
cdn,
redis,
usage,
usageEstimator,
commerce,
dbMigrations,
rateLimit,
billing,
emails,
supertokens,
s3,
Expand Down Expand Up @@ -75,10 +71,8 @@ export function deployGraphQL({
s3Mirror: S3;
s3AuditLog: S3;
usage: Usage;
usageEstimator: UsageEstimator;
dbMigrations: DbMigrations;
rateLimit: RateLimitService;
billing: StripeBillingService;
commerce: CommerceService;
emails: Emails;
supertokens: Supertokens;
zendesk: Zendesk;
Expand Down Expand Up @@ -125,15 +119,13 @@ export function deployGraphQL({
...apiEnv,
SENTRY: sentry.enabled ? '1' : '0',
REQUEST_LOGGING: '0', // disabled
BILLING_ENDPOINT: serviceLocalEndpoint(billing.service),
COMMERCE_ENDPOINT: serviceLocalEndpoint(commerce.service),
TOKENS_ENDPOINT: serviceLocalEndpoint(tokens.service),
WEBHOOKS_ENDPOINT: serviceLocalEndpoint(webhooks.service),
SCHEMA_ENDPOINT: serviceLocalEndpoint(schema.service),
SCHEMA_POLICY_ENDPOINT: serviceLocalEndpoint(schemaPolicy.service),
HIVE_USAGE_ENDPOINT: serviceLocalEndpoint(usage.service),
RATE_LIMIT_ENDPOINT: serviceLocalEndpoint(rateLimit.service),
EMAILS_ENDPOINT: serviceLocalEndpoint(emails.service),
USAGE_ESTIMATOR_ENDPOINT: serviceLocalEndpoint(usageEstimator.service),
WEB_APP_URL: `https://${environment.appDns}`,
GRAPHQL_PUBLIC_ORIGIN: `https://${environment.appDns}`,
CDN_CF: '1',
Expand Down Expand Up @@ -166,8 +158,8 @@ export function deployGraphQL({
redis.service,
clickhouse.deployment,
clickhouse.service,
rateLimit.deployment,
rateLimit.service,
commerce.deployment,
commerce.service,
],
)
// GitHub App
Expand Down
70 changes: 0 additions & 70 deletions deployment/services/rate-limit.ts

This file was deleted.

Loading
Loading