|
| 1 | +import * as ros from '@alicloud/ros-cdk-core'; |
| 2 | +import { replaceReference } from '../../common'; |
| 3 | +import { ActionContext, DatabaseDomain, DatabaseEngineMode, DatabaseEnum } from '../../types'; |
| 4 | +import { isEmpty } from 'lodash'; |
| 5 | +import * as esServerless from '@alicloud/ros-cdk-elasticsearchserverless'; |
| 6 | + |
| 7 | +export const resolveDatabases = ( |
| 8 | + scope: ros.Construct, |
| 9 | + databases: Array<DatabaseDomain> | undefined, |
| 10 | + context: ActionContext, |
| 11 | +) => { |
| 12 | + if (isEmpty(databases)) { |
| 13 | + return undefined; |
| 14 | + } |
| 15 | + databases!.forEach((db) => { |
| 16 | + if ([DatabaseEnum.ELASTICSEARCH_SERVERLESS].includes(db.type)) { |
| 17 | + new esServerless.App( |
| 18 | + scope, |
| 19 | + replaceReference(db.key, context), |
| 20 | + { |
| 21 | + appName: replaceReference(db.name, context), |
| 22 | + appVersion: db.version, |
| 23 | + authentication: { |
| 24 | + basicAuth: [ |
| 25 | + { |
| 26 | + password: replaceReference(db.security.basicAuth.password, context), |
| 27 | + }, |
| 28 | + ], |
| 29 | + }, |
| 30 | + quotaInfo: { |
| 31 | + cu: db.cu, |
| 32 | + storage: db.storageSize, |
| 33 | + appType: db.engineMode === DatabaseEngineMode.TIMESERIES ? 'TRIAL' : 'STANDARD', |
| 34 | + }, |
| 35 | + // network: [ |
| 36 | + // { |
| 37 | + // type: 'PUBLIC_KIBANA', |
| 38 | + // enabled: true, |
| 39 | + // whiteIpGroup: [{ groupName: 'default', ips: ['0.0.0.0/24'] }], |
| 40 | + // }, |
| 41 | + // { |
| 42 | + // type: 'PUBLIC_ES', |
| 43 | + // enabled: true, |
| 44 | + // whiteIpGroup: [{ groupName: 'default', ips: ['0.0.0.0/24'] }], |
| 45 | + // }, |
| 46 | + // ], |
| 47 | + }, |
| 48 | + true, |
| 49 | + ); |
| 50 | + } |
| 51 | + }); |
| 52 | +}; |
0 commit comments