From 332427f013b4af92d9bc3be219afd1eb8eed1dc4 Mon Sep 17 00:00:00 2001 From: Steven Hoang Date: Fri, 23 Aug 2024 09:33:44 +0800 Subject: [PATCH 1/2] update --- src/Builder/ServiceBusBuilder.ts | 102 +++++++++++++++---------------- src/Common/Naming.ts | 2 +- src/KeyVault/CustomHelper.ts | 2 +- src/KeyVault/Helper.ts | 7 ++- src/Storage/Helper.ts | 49 +++------------ src/Storage/index.ts | 54 +++++++++------- src/env.d.ts | 8 --- src/env.ts | 58 ++++++++++++++++++ src/envHelper.ts | 51 ---------------- src/index.ts | 3 +- tsconfig.json | 3 +- 11 files changed, 159 insertions(+), 180 deletions(-) delete mode 100644 src/env.d.ts create mode 100644 src/env.ts delete mode 100644 src/envHelper.ts diff --git a/src/Builder/ServiceBusBuilder.ts b/src/Builder/ServiceBusBuilder.ts index 166da803..b336dcc1 100644 --- a/src/Builder/ServiceBusBuilder.ts +++ b/src/Builder/ServiceBusBuilder.ts @@ -1,15 +1,5 @@ -import { - IServiceBusBuilder, - IServiceBusSkuBuilder, - ServiceBusBuilderArgs, - ServiceBusOptions, - ServiceBusQueueArgs, - ServiceBusSkuTypes, - ServiceBusSubArgs, - ServiceBusTopicArgs, - Builder, -} from './types'; - +import * as types from './types'; +import env from '../env'; import { NetworkPropsType, ResourceInfo, @@ -22,7 +12,7 @@ import { addEncryptKey } from '../KeyVault/Helper'; import { addCustomSecrets } from '../KeyVault/CustomHelper'; import { ServiceBusPrivateLink } from '../VNet'; -const defaultQueueOptions: ServiceBusQueueArgs = { +const defaultQueueOptions: types.ServiceBusQueueArgs = { //duplicateDetectionHistoryTimeWindow: 'P10M', //maxMessageSizeInKilobytes: 1024, //autoDeleteOnIdle: isPrd ? 'P180D' : 'P90D', @@ -36,7 +26,7 @@ const defaultQueueOptions: ServiceBusQueueArgs = { deadLetteringOnMessageExpiration: true, }; -const defaultTopicOptions: ServiceBusTopicArgs = { +const defaultTopicOptions: types.ServiceBusTopicArgs = { //duplicateDetectionHistoryTimeWindow: 'P10M', //maxMessageSizeInKilobytes: 1024, //autoDeleteOnIdle: isPrd ? 'P180D' : 'P90D', @@ -46,7 +36,7 @@ const defaultTopicOptions: ServiceBusTopicArgs = { enableBatchedOperations: true, }; -const defaultSubOptions: ServiceBusSubArgs = { +const defaultSubOptions: types.ServiceBusSubArgs = { duplicateDetectionHistoryTimeWindow: 'P10M', autoDeleteOnIdle: isPrd ? 'P180D' : 'P90D', defaultMessageTimeToLive: isPrd ? 'P30D' : 'P5D', @@ -57,33 +47,33 @@ const defaultSubOptions: ServiceBusSubArgs = { }; class ServiceBusBuilder - extends Builder - implements IServiceBusBuilder, IServiceBusSkuBuilder + extends types.Builder + implements types.IServiceBusBuilder, types.IServiceBusSkuBuilder { private readonly _instanceName: string; private _sbInstance: bus.Namespace | undefined = undefined; private _networkInstance: bus.NamespaceNetworkRuleSet | undefined = undefined; - private _sku: ServiceBusSkuTypes = 'Basic'; + private _sku: types.ServiceBusSkuTypes = 'Basic'; private _network: NetworkPropsType | undefined = undefined; - private _queues: Record = {}; - private _topics: Record = {}; - private _options: ServiceBusOptions = {}; + private _queues: Record = {}; + private _topics: Record = {}; + private _options: types.ServiceBusOptions = {}; - constructor(private args: ServiceBusBuilderArgs) { + constructor(private args: types.ServiceBusBuilderArgs) { super(args); this._instanceName = naming.getServiceBusName(args.name); } - public withSku(sku: ServiceBusSkuTypes): IServiceBusBuilder { + public withSku(sku: types.ServiceBusSkuTypes): types.IServiceBusBuilder { this._sku = sku; return this; } - public withOptions(props: ServiceBusOptions): IServiceBusBuilder { + public withOptions(props: types.ServiceBusOptions): types.IServiceBusBuilder { this._options = props; return this; } - public withNetwork(props: NetworkPropsType): IServiceBusBuilder { + public withNetwork(props: NetworkPropsType): types.IServiceBusBuilder { if (this._sku !== 'Premium') throw new Error( "The network only support for Service Bus with 'Premium' tier.", @@ -95,19 +85,19 @@ class ServiceBusBuilder public withNetworkIf( condition: boolean, props: NetworkPropsType, - ): IServiceBusBuilder { + ): types.IServiceBusBuilder { if (condition) return this.withNetwork(props); return this; } public withQueues( - props: Record, - ): IServiceBusBuilder { + props: Record, + ): types.IServiceBusBuilder { this._queues = { ...this._queues, ...props }; return this; } public withTopics( - props: Record, - ): IServiceBusBuilder { + props: Record, + ): types.IServiceBusBuilder { this._topics = { ...this._topics, ...props }; return this; } @@ -139,7 +129,7 @@ class ServiceBusBuilder type: this.args.envUIDInfo ? bus.ManagedServiceIdentityType.SystemAssigned_UserAssigned : bus.ManagedServiceIdentityType.SystemAssigned, - //all uuid must assigned here before use + //all uuid must assign here before use userAssignedIdentities: this.args.envUIDInfo ? [this.args.envUIDInfo.id] : undefined, @@ -235,7 +225,7 @@ class ServiceBusBuilder ['both', 'send', 'listen'].map((type) => this.buildConnectionString({ type, - level: 'topic', + level: 'queue', name: queueName, dependsOn: queue, }), @@ -258,7 +248,7 @@ class ServiceBusBuilder { dependsOn: this._sbInstance }, ); - ['both', 'send', 'listen'].map((type) => + ['manage', 'both', 'send', 'listen'].map((type) => this.buildConnectionString({ type, level: 'topic', @@ -284,7 +274,7 @@ class ServiceBusBuilder subs, }: { topic: bus.Topic; - subs?: Record; + subs?: Record; } & WithNamedType) { if (!subs) return; @@ -326,7 +316,7 @@ class ServiceBusBuilder name, dependsOn, }: { - type: 'send' | 'listen' | 'both' | string; + type: 'send' | 'listen' | 'both' | 'manage' | string; level: 'queue' | 'topic' | string; } & WithDependsOn & WithNamedType) { @@ -334,12 +324,18 @@ class ServiceBusBuilder const authorizationRuleName = `${level}-${name}-${type}`; const n = `${this._instanceName}-${authorizationRuleName}`; - const permissions = - type == 'both' - ? [bus.AccessRights.Send, bus.AccessRights.Listen] - : type === 'send' - ? [bus.AccessRights.Send] - : [bus.AccessRights.Listen]; + const rights = + type === 'manage' + ? [ + bus.AccessRights.Manage, + bus.AccessRights.Send, + bus.AccessRights.Listen, + ] + : type == 'both' + ? [bus.AccessRights.Send, bus.AccessRights.Listen] + : type === 'send' + ? [bus.AccessRights.Send] + : [bus.AccessRights.Listen]; const rule = level === 'topic' @@ -350,7 +346,7 @@ class ServiceBusBuilder authorizationRuleName, topicName: name, namespaceName: this._instanceName, - rights: permissions, + rights, }, { dependsOn }, ) @@ -361,7 +357,7 @@ class ServiceBusBuilder authorizationRuleName, queueName: name, namespaceName: this._instanceName, - rights: permissions, + rights, }, { dependsOn }, ); @@ -386,13 +382,15 @@ class ServiceBusBuilder vaultInfo: this.args.vaultInfo!, contentType: `ServiceBus ${n}`, dependsOn: rule, - items: [ - { name: `${n}-primary`, value: keys.primaryConnectionString }, - { - name: `${n}-secondary`, - value: keys.secondaryConnectionString, - }, - ], + items: env.DPA_CONN_ENABLE_SECONDARY + ? [ + { name: `${n}-primary`, value: keys.primaryConnectionString }, + { + name: `${n}-secondary`, + value: keys.secondaryConnectionString, + }, + ] + : [{ name: n, value: keys.primaryConnectionString }], }); }); } @@ -411,5 +409,5 @@ class ServiceBusBuilder } } -export default (props: ServiceBusBuilderArgs) => - new ServiceBusBuilder(props) as IServiceBusSkuBuilder; +export default (props: types.ServiceBusBuilderArgs) => + new ServiceBusBuilder(props) as types.IServiceBusSkuBuilder; diff --git a/src/Common/Naming.ts b/src/Common/Naming.ts index 1fd43ee9..bee54bdf 100644 --- a/src/Common/Naming.ts +++ b/src/Common/Naming.ts @@ -1,5 +1,5 @@ import { ConventionProps, ReplacePattern, NamingType } from '../types'; -import * as env from '../envHelper'; +import env from '../env'; import { currentCountryCode } from './AzureEnv'; import { organization, stack } from './StackEnv'; diff --git a/src/KeyVault/CustomHelper.ts b/src/KeyVault/CustomHelper.ts index 55dc8a7a..ce366b29 100644 --- a/src/KeyVault/CustomHelper.ts +++ b/src/KeyVault/CustomHelper.ts @@ -4,7 +4,7 @@ import { VaultSecretResource } from '@drunk-pulumi/azure-providers/VaultSecret'; import { KeyVaultInfo, NamedBasicArgs, NamedWithVaultType } from '../types'; import { getSecret } from '../Common/ConfigHelper'; import { getVaultItemName } from './Helper'; -import * as env from '../envHelper'; +import env from '../env'; interface Props extends Required { /** The value of the secret. If Value is not provided the secret will be got from config*/ diff --git a/src/KeyVault/Helper.ts b/src/KeyVault/Helper.ts index 2f3b07e5..cd944653 100644 --- a/src/KeyVault/Helper.ts +++ b/src/KeyVault/Helper.ts @@ -3,10 +3,13 @@ import { KeyVaultInfo, NamedWithVaultType, WithVaultInfo } from '../types'; import getKeyVaultBase from '@drunk-pulumi/azure-providers/AzBase/KeyVaultBase'; import { VaultKeyResource } from '@drunk-pulumi/azure-providers'; import { stack, removeLeadingAndTrailingDash } from '../Common'; -import * as env from '../envHelper'; +import env from '../env'; /** Get Vault Secret Name. Remove the stack name and replace all _ with - then lower cases. */ -export const getVaultItemName = (name: string, currentStack: string = stack) => { +export const getVaultItemName = ( + name: string, + currentStack: string = stack, +) => { name = name .replace(new RegExp(currentStack, 'g'), '') // Replace occurrences of "stack" variable with "-" .replace(/\.|_|\s/g, '-') // Replace ".", "_", and spaces with "-" diff --git a/src/Storage/Helper.ts b/src/Storage/Helper.ts index 66fce567..a5c22c03 100644 --- a/src/Storage/Helper.ts +++ b/src/Storage/Helper.ts @@ -1,4 +1,5 @@ import { cleanName, defaultSubScope, naming } from '../Common'; +import env from '../env'; import { getSecrets } from '../KeyVault/Helper'; import { KeyVaultInfo, @@ -15,14 +16,20 @@ const getStorageSecrets = ({ storageName: string; vaultInfo: KeyVaultInfo; }): StorageConnectionInfo => { - const primaryKey = `${storageName}-key-primary`; + const primaryKey = env.DPA_CONN_ENABLE_SECONDARY + ? `${storageName}-key-primary` + : `${storageName}-key`; const secondaryKey = `${storageName}-key-secondary`; - const primaryConnection = `${storageName}-conn-primary`; + const primaryConnection = env.DPA_CONN_ENABLE_SECONDARY + ? `${storageName}-conn-primary` + : `${storageName}-conn`; const secondaryConnection = `${storageName}-conn-secondary`; return getSecrets({ vaultInfo, - names: { primaryKey, secondaryKey, primaryConnection, secondaryConnection }, + names: env.DPA_CONN_ENABLE_SECONDARY + ? { primaryKey, secondaryKey, primaryConnection, secondaryConnection } + : { primaryKey, primaryConnection }, }); }; @@ -48,39 +55,3 @@ export const getStorageInfo = ({ id: interpolate`${defaultSubScope}/resourceGroups/${group.resourceGroupName}/providers/Microsoft.Storage/storageAccounts/${name}`, }; }; - -// export const getStorageSecretsById = async ({ -// storageId, -// vaultInfo, -// }: { -// storageId: string; -// vaultInfo: KeyVaultInfo; -// }) => { -// const info = rsInfo.getResourceInfoFromId(storageId); -// const secrets = info -// ? await getStorageSecrets({ -// name: info.name, -// nameFormatted: true, -// vaultInfo, -// }) -// : undefined; -// -// return secrets ? { info, secrets } : undefined; -// }; - -// export const getAccountSAS = ({ group, name }: BasicResourceArgs) => { -// const now = new Date(); -// const expireDate = new Date(); -// expireDate.setMonth(expireDate.getMonth() + 3); -// -// return storage.listStorageAccountSAS({ -// accountName: name, -// ...group, -// resourceTypes: storage.SignedResourceTypes.C, -// services: storage.Services.B, -// permissions: storage.Permissions.W, -// protocols: storage.HttpProtocol.Https, -// sharedAccessStartTime: now.toISOString(), -// sharedAccessExpiryTime: expireDate.toISOString(), -// }); -// }; diff --git a/src/Storage/index.ts b/src/Storage/index.ts index b881af18..ca0371bc 100644 --- a/src/Storage/index.ts +++ b/src/Storage/index.ts @@ -1,4 +1,5 @@ import * as storage from '@pulumi/azure-native/storage'; +import env from '../env'; import { BasicEncryptResourceArgs, PrivateLinkPropsType, @@ -319,11 +320,6 @@ function Storage({ //Add connection into Key vault if (vaultInfo) { - const primaryKeyName = `${name}-key-primary`; - const secondaryKeyName = `${name}-key-secondary`; - const primaryConnectionKeyName = `${name}-conn-primary`; - const secondConnectionKeyName = `${name}-conn-secondary`; - const keys = ( await storage.listStorageAccountKeys({ accountName: name, @@ -339,24 +335,36 @@ function Storage({ addCustomSecrets({ vaultInfo, contentType: `Storage: ${name}`, - items: [ - { - name: primaryKeyName, - value: keys[0].key, - }, - { - name: secondaryKeyName, - value: keys[1].key, - }, - { - name: primaryConnectionKeyName, - value: keys[0].connectionString, - }, - { - name: secondConnectionKeyName, - value: keys[1].connectionString, - }, - ], + items: env.DPA_CONN_ENABLE_SECONDARY + ? [ + { + name: `${name}-key-primary`, + value: keys[0].key, + }, + { + name: `${name}-key-secondary`, + value: keys[1].key, + }, + { + name: `${name}-conn-primary`, + value: keys[0].connectionString, + }, + { + name: `${name}-conn-secondary`, + value: keys[1].connectionString, + }, + ] + : [ + { + name: `${name}-key`, + value: keys[0].key, + }, + + { + name: `${name}-conn`, + value: keys[0].connectionString, + }, + ], }); } }); diff --git a/src/env.d.ts b/src/env.d.ts deleted file mode 100644 index 175b5428..00000000 --- a/src/env.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace NodeJS { - interface ProcessEnv { - DPA_NAMING_DISABLE_PREFIX?: string; - DPA_NAMING_DISABLE_REGION?: string; - DPA_NAMING_DISABLE_SUFFIX?: string; - DPA_VAULT_DISABLE_FORMAT_NAME?: string; - } -} diff --git a/src/env.ts b/src/env.ts new file mode 100644 index 00000000..a5fec0c1 --- /dev/null +++ b/src/env.ts @@ -0,0 +1,58 @@ +import * as process from 'node:process'; +import * as console from 'node:console'; + +declare namespace NodeJS { + interface ProcessEnv { + //Disabling + /** Allows to disable 'prefix' from naming builder.*/ + DPA_NAMING_DISABLE_PREFIX?: string; + /** Allows to disable 'region' from naming builder.*/ + DPA_NAMING_DISABLE_REGION?: string; + /** Allows to disable 'suffix' from naming builder.*/ + DPA_NAMING_DISABLE_SUFFIX?: string; + /** Allows to disable vault item naming formating (remove env name from item name).*/ + DPA_VAULT_DISABLE_FORMAT_NAME?: string; + //Enabling + /** Allows to disable/enable adding secondary key or connection string into Vault.*/ + DPA_CONN_ENABLE_SECONDARY?: string; + } +} + +class Env { + static getString(key: string): string | undefined { + return process.env[key]; + } + + static getNumber(key: string): number | undefined { + const value = process.env[key]; + if (value === undefined) { + return undefined; + } + const parsedValue = parseFloat(value); + if (isNaN(parsedValue)) { + return undefined; + } + return parsedValue; + } + + static getBoolean(key: string): boolean { + const value = process.env[key]; + if (value === undefined) { + return false; + } + return value === 'true' || value === '1'; + } +} + +const env = { + DPA_NAMING_DISABLE_PREFIX: Env.getBoolean('DPA_NAMING_DISABLE_PREFIX'), + DPA_NAMING_DISABLE_SUFFIX: Env.getBoolean('DPA_NAMING_DISABLE_SUFFIX'), + DPA_NAMING_DISABLE_REGION: Env.getBoolean('DPA_NAMING_DISABLE_REGION'), + DPA_VAULT_DISABLE_FORMAT_NAME: Env.getBoolean( + 'DPA_VAULT_DISABLE_FORMAT_NAME', + ), + DPA_CONN_ENABLE_SECONDARY: Env.getBoolean('DPA_CONN_ENABLE_SECONDARY'), +}; + +export default env; +console.log('DPA_ENV', env); diff --git a/src/envHelper.ts b/src/envHelper.ts deleted file mode 100644 index 5262164a..00000000 --- a/src/envHelper.ts +++ /dev/null @@ -1,51 +0,0 @@ -import * as process from 'node:process'; -import * as console from 'node:console'; - -class EnvHelper { - static getString(key: string): string | undefined { - return process.env[key]; - } - - static getNumber(key: string): number | undefined { - const value = process.env[key]; - if (value === undefined) { - return undefined; - } - const parsedValue = parseFloat(value); - if (isNaN(parsedValue)) { - return undefined; - } - return parsedValue; - } - - static getBoolean(key: string): boolean { - const value = process.env[key]; - if (value === undefined) { - return false; - } - return value === 'true' || value === '1'; - } -} - -export const DPA_NAMING_DISABLE_PREFIX = EnvHelper.getBoolean( - 'DPA_NAMING_DISABLE_PREFIX', -); - -export const DPA_NAMING_DISABLE_SUFFIX = EnvHelper.getBoolean( - 'DPA_NAMING_DISABLE_SUFFIX', -); - -export const DPA_NAMING_DISABLE_REGION = EnvHelper.getBoolean( - 'DPA_NAMING_DISABLE_REGION', -); - -export const DPA_VAULT_DISABLE_FORMAT_NAME = EnvHelper.getBoolean( - 'DPA_VAULT_DISABLE_FORMAT_NAME', -); - -console.log('DPA_ENV', { - DPA_VAULT_DISABLE_FORMAT_NAME, - DPA_NAMING_DISABLE_PREFIX, - DPA_NAMING_DISABLE_REGION, - DPA_NAMING_DISABLE_SUFFIX, -}); diff --git a/src/index.ts b/src/index.ts index da384991..eeefe054 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,2 @@ -export * from "./Builder"; +export * from './Builder'; +export * from './types'; diff --git a/tsconfig.json b/tsconfig.json index 711e1304..5798d2d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -183,8 +183,7 @@ "src/VNet/Vnet.ts", "src/VNet/index.ts", "src/VNet/types.ts", - "src/env.d.ts", - "src/envHelper.ts", + "src/env.ts", "src/index.ts", "src/types.ts" ] From abcb8cd5786916d90a652632a3b9642983985f7b Mon Sep 17 00:00:00 2001 From: Steven Hoang Date: Fri, 23 Aug 2024 09:48:11 +0800 Subject: [PATCH 2/2] update --- src/Builder/AppConfigBuilder.ts | 15 ++++++++++----- src/Builder/RedisCacheBuilder.ts | 31 ++++++++++++++++++++----------- src/Builder/SignalRBuilder.ts | 31 ++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/Builder/AppConfigBuilder.ts b/src/Builder/AppConfigBuilder.ts index 31f5d5e7..3d5d6ce5 100644 --- a/src/Builder/AppConfigBuilder.ts +++ b/src/Builder/AppConfigBuilder.ts @@ -5,11 +5,12 @@ import { Builder, IAppConfigBuilder, } from './types'; +import env from '../env'; import { ResourceInfo } from '../types'; import { isPrd, naming } from '../Common'; import * as appConfig from '@pulumi/azure-native/appconfiguration/v20230901preview'; import { addEncryptKey } from '../KeyVault/Helper'; -import { addCustomSecret } from '../KeyVault/CustomHelper'; +import { addCustomSecret, addCustomSecrets } from '../KeyVault/CustomHelper'; import { AppConfigPrivateLink } from '../VNet'; class AppConfigBuilder @@ -122,10 +123,14 @@ class AppConfigBuilder }); if (keys.value) { - const readPrimaryConnectionStringKey = `${this._instanceName}-read-primary-connection-string`; - const readSecondaryConnectionStringKey = `${this._instanceName}-read-secondary-connection-string`; - - keys.value.map((key) => { + const readPrimaryConnectionStringKey = env.DPA_CONN_ENABLE_SECONDARY + ? `${this._instanceName}-read-conn-primary` + : `${this._instanceName}-read-conn`; + const readSecondaryConnectionStringKey = `${this._instanceName}-read-conn-secondary`; + + keys.value.forEach((key) => { + if (!env.DPA_CONN_ENABLE_SECONDARY && !key.name.includes('Primary')) + return; //Only Read Connection String here if (key.readOnly) { addCustomSecret({ diff --git a/src/Builder/RedisCacheBuilder.ts b/src/Builder/RedisCacheBuilder.ts index 984eaf39..0b8132a8 100644 --- a/src/Builder/RedisCacheBuilder.ts +++ b/src/Builder/RedisCacheBuilder.ts @@ -5,6 +5,7 @@ import { RedisCacheBuilderArgs, RedisCacheSkuBuilder, } from './types'; +import env from '../env'; import { NetworkPropsType, ResourceInfo } from '../types'; import { isPrd, naming } from '../Common'; import * as cache from '@pulumi/azure-native/cache'; @@ -113,17 +114,25 @@ class RedisCacheBuilder vaultInfo, contentType: 'Redis Cache', dependsOn: this._redisInstance, - items: [ - { name: `${this._instanceName}-host`, value: h }, - { - name: `${this._instanceName}-primary-conn`, - value: `${h}:6380,password=${keys.primaryKey},ssl=True,abortConnect=False`, - }, - { - name: `${this._instanceName}-secondary-conn`, - value: `${h}:6380,password=${keys.secondaryKey},ssl=True,abortConnect=False`, - }, - ], + items: env.DPA_CONN_ENABLE_SECONDARY + ? [ + { name: `${this._instanceName}-host`, value: h }, + { + name: `${this._instanceName}-conn-primary`, + value: `${h}:6380,password=${keys.primaryKey},ssl=True,abortConnect=False`, + }, + { + name: `${this._instanceName}-conn-secondary`, + value: `${h}:6380,password=${keys.secondaryKey},ssl=True,abortConnect=False`, + }, + ] + : [ + { name: `${this._instanceName}-host`, value: h }, + { + name: `${this._instanceName}-conn`, + value: `${h}:6380,password=${keys.primaryKey},ssl=True,abortConnect=False`, + }, + ], }); }); } diff --git a/src/Builder/SignalRBuilder.ts b/src/Builder/SignalRBuilder.ts index 79ba7052..c85d684e 100644 --- a/src/Builder/SignalRBuilder.ts +++ b/src/Builder/SignalRBuilder.ts @@ -8,6 +8,7 @@ import { SignalROptionsBuilder, SignalRSkuBuilderType, } from './types'; +import env from '../env'; import { PrivateLinkPropsType, ResourceInfo } from '../types'; import { naming } from '../Common'; import { Input } from '@pulumi/pulumi'; @@ -143,17 +144,25 @@ class SignalRBuilder vaultInfo, contentType: 'SignalR', dependsOn: this._signalRInstance, - items: [ - { name: `${this._instanceName}-host`, value: h }, - { - name: `${this._instanceName}-primaryConnection`, - value: keys.primaryConnectionString!, - }, - { - name: `${this._instanceName}-secondaryConnection`, - value: keys.secondaryConnectionString!, - }, - ], + items: env.DPA_CONN_ENABLE_SECONDARY + ? [ + { name: `${this._instanceName}-host`, value: h }, + { + name: `${this._instanceName}-conn-primary`, + value: keys.primaryConnectionString!, + }, + { + name: `${this._instanceName}-conn-secondary`, + value: keys.secondaryConnectionString!, + }, + ] + : [ + { name: `${this._instanceName}-host`, value: h }, + { + name: `${this._instanceName}-conn`, + value: keys.primaryConnectionString!, + }, + ], }); }); }