From ff8ce76fe688cf44cbe85b0b90c971009e1e5784 Mon Sep 17 00:00:00 2001 From: Hemal Shah Date: Wed, 14 Jan 2026 14:49:59 +0000 Subject: [PATCH 1/2] feat(azure-redis): convert to azure managed redis --- src/lib/azure/services/redis/main.ts | 22 +++++++++---------- src/lib/azure/services/redis/types.ts | 4 ++-- src/test/azure/services/redis-manager.test.ts | 20 ++++++++--------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/lib/azure/services/redis/main.ts b/src/lib/azure/services/redis/main.ts index 695e093f..238f34ff 100644 --- a/src/lib/azure/services/redis/main.ts +++ b/src/lib/azure/services/redis/main.ts @@ -1,8 +1,8 @@ import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js' -import { RedisCache } from '@cdktf/provider-azurerm/lib/redis-cache/index.js' +import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js' import { CommonAzureConstruct } from '../../common/index.js' import { createAzureTfOutput } from '../../utils/index.js' -import { RedisCacheProps } from './types.js' +import { ManagedRedisProps } from './types.js' /** * @classdesc Provides operations on Azure Redis @@ -16,7 +16,7 @@ import { RedisCacheProps } from './types.js' * constructor(parent: Construct, id: string, props: CommonAzureStackProps) { * super(parent, id, props) * this.props = props - * this.redisManager.createRedis('MyRedisCache', this, props) + * this.redisManager.createRedis('MyManagedRedis', this, props) * } * } * ``` @@ -27,9 +27,9 @@ export class AzureRedisManager { * @param id scoped id of the resource * @param scope scope in which this resource is defined * @param props redis cache properties - * @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/redisCache.typescript.md} + * @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/managedRedis.typescript.md} */ - public createRedisCache(id: string, scope: CommonAzureConstruct, props: RedisCacheProps) { + public createManagedRedis(id: string, scope: CommonAzureConstruct, props: ManagedRedisProps) { if (!props) throw `Props undefined for ${id}` const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-rc-rg`, { @@ -40,9 +40,9 @@ export class AzureRedisManager { if (!resourceGroup) throw `Resource group undefined for ${id}` - const redisCache = new RedisCache(scope, `${id}-rc`, { + const managedRedis = new ManagedRedis(scope, `${id}-rc`, { ...props, - name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.redisCache), + name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.managedRedis), location: resourceGroup.location, resourceGroupName: resourceGroup.name, tags: props.tags ?? { @@ -50,10 +50,10 @@ export class AzureRedisManager { }, }) - createAzureTfOutput(`${id}-redisCacheName`, scope, redisCache.name) - createAzureTfOutput(`${id}-redisCacheFriendlyUniqueId`, scope, redisCache.friendlyUniqueId) - createAzureTfOutput(`${id}-redisCacheId`, scope, redisCache.id) + createAzureTfOutput(`${id}-managedRedisName`, scope, managedRedis.name) + createAzureTfOutput(`${id}-managedRedisFriendlyUniqueId`, scope, managedRedis.friendlyUniqueId) + createAzureTfOutput(`${id}-managedRedisId`, scope, managedRedis.id) - return redisCache + return managedRedis } } diff --git a/src/lib/azure/services/redis/types.ts b/src/lib/azure/services/redis/types.ts index c5df1d04..0145ea17 100644 --- a/src/lib/azure/services/redis/types.ts +++ b/src/lib/azure/services/redis/types.ts @@ -1,3 +1,3 @@ -import { RedisCacheConfig } from '@cdktf/provider-azurerm/lib/redis-cache/index.js' +import { ManagedRedisConfig } from '@cdktf/provider-azurerm/lib/managed-redis/index.js' -export interface RedisCacheProps extends RedisCacheConfig {} +export interface ManagedRedisProps extends ManagedRedisConfig {} diff --git a/src/test/azure/services/redis-manager.test.ts b/src/test/azure/services/redis-manager.test.ts index e6f00473..a4a174df 100644 --- a/src/test/azure/services/redis-manager.test.ts +++ b/src/test/azure/services/redis-manager.test.ts @@ -5,11 +5,11 @@ import { CommonAzureConstruct, CommonAzureStack, CommonAzureStackProps, - RedisCacheProps, + ManagedRedisProps, } from '../../../lib/azure/index.js' interface TestAzureStackProps extends CommonAzureStackProps { - testRedisCache: RedisCacheProps + testRedisCache: ManagedRedisProps testAttribute?: string } @@ -56,7 +56,7 @@ class TestCommonConstruct extends CommonAzureConstruct { constructor(parent: Construct, name: string, props: TestAzureStackProps) { super(parent, name, props) - this.redisManager.createRedisCache(`test-redis-cache-${this.props.stage}`, this, this.props.testRedisCache) + this.redisManager.createManagedRedis(`test-redis-cache-${this.props.stage}`, this, this.props.testRedisCache) } } @@ -92,23 +92,23 @@ describe('TestAzureRedisConstruct', () => { describe('TestAzureRedisConstruct', () => { test('provisions outputs as expected', () => { expect(JSON.parse(construct).output).toMatchObject({ - testRedisCacheDevRedisCacheFriendlyUniqueId: { + testRedisCacheDevManagedRedisFriendlyUniqueId: { value: 'test-redis-cache-dev-rc', }, - testRedisCacheDevRedisCacheId: { - value: '${azurerm_redis_cache.test-redis-cache-dev-rc.id}', + testRedisCacheDevManagedRedisId: { + value: '${azurerm_managed_redis.test-redis-cache-dev-rc.id}', }, - testRedisCacheDevRedisCacheName: { - value: '${azurerm_redis_cache.test-redis-cache-dev-rc.name}', + testRedisCacheDevManagedRedisName: { + value: '${azurerm_managed_redis.test-redis-cache-dev-rc.name}', }, }) }) }) describe('TestAzureRedisConstruct', () => { - test('provisions redis cache as expected', () => { + test('provisions managed redis as expected', () => { expect( - Testing.toHaveResourceWithProperties(construct, 'RedisCache', { + Testing.toHaveResourceWithProperties(construct, 'ManagedRedis', { capacity: 2, family: 'C', location: '${data.azurerm_resource_group.test-redis-cache-dev-rc-rg.location}', From 640259f05b6df1302ae9f5a10d63b0ab727a4348 Mon Sep 17 00:00:00 2001 From: Hemal Shah Date: Fri, 16 Jan 2026 09:33:08 +0000 Subject: [PATCH 2/2] feat(azure-redis): convert to azure managed redis --- src/lib/azure/services/api-management/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/azure/services/api-management/main.ts b/src/lib/azure/services/api-management/main.ts index a4e7d803..c8c0a6e5 100644 --- a/src/lib/azure/services/api-management/main.ts +++ b/src/lib/azure/services/api-management/main.ts @@ -14,7 +14,7 @@ import { DataAzurermApiManagementConfig, } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management/index.js' import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js' -import { RedisCache } from '@cdktf/provider-azurerm/lib/redis-cache/index.js' +import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js' import _ from 'lodash' import { CommonAzureConstruct } from '../../common/index.js' import { createAzureTfOutput } from '../../utils/index.js' @@ -55,7 +55,7 @@ export class AzureApiManagementManager { scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey'], - externalRedisCache?: RedisCache + externalRedisCache?: ManagedRedis ) { if (!props) throw `Props undefined for ${id}` @@ -91,7 +91,7 @@ export class AzureApiManagementManager { new ApiManagementRedisCache(scope, `${id}-am-redis-cache`, { name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementRedisCache), apiManagementId: apiManagement.id, - connectionString: externalRedisCache.primaryConnectionString, + connectionString: `${externalRedisCache.name}:10000,password=${externalRedisCache.defaultDatabase.primaryAccessKey},ssl=True,abortConnect=False`, cacheLocation: externalRedisCache.location, redisCacheId: externalRedisCache.id, })