UNPKG

@studion/infra-code-blocks

Version:
36 lines (35 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Redis = void 0; const pulumi = require("@pulumi/pulumi"); const upstash = require("@upstash/pulumi"); const aws = require("@pulumi/aws"); const constants_1 = require("../constants"); const defaults = { region: 'us-east-1', }; class Redis extends pulumi.ComponentResource { constructor(name, args, opts) { super('studion:Redis', name, {}, opts); this.username = 'default'; const project = pulumi.getProject(); const stack = pulumi.getStack(); const argsWithDefaults = Object.assign({}, defaults, args); this.instance = new upstash.RedisDatabase(name, { databaseName: `${argsWithDefaults.dbName}-${stack}`, region: argsWithDefaults.region, eviction: true, tls: true, }, { provider: opts.provider, parent: this }); this.passwordSecret = new aws.secretsmanager.Secret(`${name}-password-secret`, { namePrefix: `${stack}/${project}/RedisPassword-`, tags: constants_1.commonTags, }, { parent: this, dependsOn: [this.instance] }); const passwordSecretValue = new aws.secretsmanager.SecretVersion(`${name}-password-secret-value`, { secretId: this.passwordSecret.id, secretString: this.instance.password, }, { parent: this, dependsOn: [this.passwordSecret] }); this.registerOutputs(); } } exports.Redis = Redis;