-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathredis.ts
47 lines (40 loc) · 1.22 KB
/
redis.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as pulumi from '@pulumi/pulumi';
import { serviceLocalHost } from '../utils/local-endpoint';
import { Redis as RedisStore } from '../utils/redis';
import { ServiceSecret } from '../utils/secrets';
import { Environment } from './environment';
const redisConfig = new pulumi.Config('redis');
export class RedisSecret extends ServiceSecret<{
password: string | pulumi.Output<string>;
host: string | pulumi.Output<string>;
port: string | pulumi.Output<string>;
}> {}
export type Redis = ReturnType<typeof deployRedis>;
export function deployRedis(input: { environment: Environment }) {
const redisPassword = redisConfig.requireSecret('password');
const redisApi = new RedisStore({
password: redisPassword,
}).deploy({
limits: input.environment.isProduction
? {
memory: '6Gi',
cpu: '1000m',
}
: {
memory: '100Mi',
cpu: '50m',
},
});
const host = serviceLocalHost(redisApi.service);
const port = String(redisApi.redisPort);
const secret = new RedisSecret('redis', {
password: redisConfig.requireSecret('password'),
host,
port,
});
return {
deployment: redisApi.deployment,
service: redisApi.service,
secret,
};
}