console/deployment/services/usage-estimation.ts
Laurin Quast 7656b7957d
feat: clean app env (#422)
* feat: document environment variables

* more env documentation

* wip

* add noop for backend env

* typo

* feat: embed environment validation/parsing in built app

* fix the sentry integration 😌

* feat: use env

* feat: decode the usage service environment

* feat: decode the webhooks service environment

* feat: disallow process.env

* feat: decode the tokens service environment

* feat: decode the stripe-billing service environment

* feat: decode server service environment

* feat: decode schema service environment

* feat: decode rate-limit service environment

* feat: decode usage-estimator service environment

* feat: decode emails service environment

* adjust env

* remove commented out code

* adjust env variable name

* use separate env variables

* env fixes

* more environmental stuff :)

* ...

* replace POSTGRES_CONNECTION_STRING with specific environment variables

* handle optional clickhouse (for now :)

* add missing POSTGRES_DB environment variable

* make ENVIRONMENT optional

* the other matters lol

* feat: support delivering mails via SMTP (#412)

* feat: optional CDN (#410)

* feat: optional CDN

* enable CDN in deployment

* enable the CDN in integration tests

* add sendmail provider

* remove unused env variables from the deployment

* only show login alert when legacy auth0 migration is enabled

* feat: make TOKENS_ENDPOINT mandatory and RATE_LIMIT_ENDPOINT optional for usage service

* feat: upgrade supertokens and enable server side email confirmation (#423)

* feat: upgrade supertokens and enable server side email confirmation

* feat: opt into required email verification

* docs: self hosting (#428)

* docs: self-hosting quick start

* Update packages/web/docs/pages/self-hosting/get-started.mdx

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>

* feat: optional GitHub and Slack environment variables (#440)

* feat: optional github integration environment variables

* feat: optional slack integration (#441)

* use latest stable supertokens

Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
2022-10-04 14:30:21 +02:00

51 lines
1.6 KiB
TypeScript

import * as pulumi from '@pulumi/pulumi';
import * as azure from '@pulumi/azure';
import { RemoteArtifactAsServiceDeployment } from '../utils/remote-artifact-as-service';
import { PackageHelper } from '../utils/pack';
import { DeploymentEnvironment } from '../types';
import { Clickhouse } from './clickhouse';
import { DbMigrations } from './db-migrations';
const commonConfig = new pulumi.Config('common');
const commonEnv = commonConfig.requireObject<Record<string, string>>('env');
export type UsageEstimator = ReturnType<typeof deployUsageEstimation>;
export function deployUsageEstimation({
storageContainer,
packageHelper,
deploymentEnv,
clickhouse,
dbMigrations,
}: {
storageContainer: azure.storage.Container;
packageHelper: PackageHelper;
deploymentEnv: DeploymentEnvironment;
clickhouse: Clickhouse;
dbMigrations: DbMigrations;
}) {
return new RemoteArtifactAsServiceDeployment(
'usage-estimator',
{
storageContainer,
replicas: 1,
readinessProbe: '/_readiness',
livenessProbe: '/_health',
env: {
...deploymentEnv,
...commonEnv,
SENTRY: commonEnv.SENTRY_ENABLED,
CLICKHOUSE_PROTOCOL: clickhouse.config.protocol,
CLICKHOUSE_HOST: clickhouse.config.host,
CLICKHOUSE_PORT: clickhouse.config.port,
CLICKHOUSE_USERNAME: clickhouse.config.username,
CLICKHOUSE_PASSWORD: clickhouse.config.password,
RELEASE: packageHelper.currentReleaseId(),
},
exposesMetrics: true,
packageInfo: packageHelper.npmPack('@hive/usage-estimator'),
port: 4000,
},
[dbMigrations]
).deploy();
}