-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcdk.ts
43 lines (37 loc) · 1.55 KB
/
cdk.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { DifyOnAwsStack } from '../lib/dify-on-aws-stack';
import { UsEast1Stack } from '../lib/us-east-1-stack';
import { EnvironmentProps } from '../lib/environment-props';
export const props: EnvironmentProps = {
awsRegion: 'us-west-2',
awsAccount: process.env.CDK_DEFAULT_ACCOUNT!,
// Set Dify version
difyImageTag: '0.15.2',
// uncomment the below for cheap configuration:
// isRedisMultiAz: false,
// useNatInstance: true,
// enableAuroraScalesToZero: true,
// useCloudFront: false,
// Please see EnvironmentProps in lib/environment-props.ts for all the available properties
};
const app = new cdk.App();
let virginia: UsEast1Stack | undefined = undefined;
if ((props.useCloudFront ?? true) && (props.domainName || props.allowedIPv4Cidrs || props.allowedIPv6Cidrs)) {
// add a unique suffix to prevent collision with different Dify instances in the same account.
virginia = new UsEast1Stack(app, `DifyOnAwsUsEast1Stack${props.subDomain ? `-${props.subDomain}` : ''}`, {
env: { region: 'us-east-1', account: props.awsAccount },
crossRegionReferences: true,
domainName: props.domainName,
allowedIpV4AddressRanges: props.allowedIPv4Cidrs,
allowedIpV6AddressRanges: props.allowedIPv6Cidrs,
});
}
new DifyOnAwsStack(app, 'DifyOnAwsStack', {
env: { region: props.awsRegion, account: props.awsAccount },
crossRegionReferences: true,
...props,
cloudFrontCertificate: virginia?.certificate,
cloudFrontWebAclArn: virginia?.webAclArn,
});