Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/azure/services/api-management/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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}`

Expand Down Expand Up @@ -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,
})
Expand Down
22 changes: 11 additions & 11 deletions src/lib/azure/services/redis/main.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
* }
* }
* ```
Expand All @@ -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`, {
Expand All @@ -40,20 +40,20 @@ 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 ?? {
environment: scope.props.stage,
},
})

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
}
}
4 changes: 2 additions & 2 deletions src/lib/azure/services/redis/types.ts
Original file line number Diff line number Diff line change
@@ -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 {}
20 changes: 10 additions & 10 deletions src/test/azure/services/redis-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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}',
Expand Down