-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
73 lines (63 loc) · 2.83 KB
/
app.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { SharedInfraStack } from './shared_infrastructure';
import { MDMServerStack } from './mdmserver/infrastructure'
import { SCEPServerStack } from './scepserver/infrastructure';
import { MDMProfileServerStack } from './mdmProfileServer/infrastructure';
import * as ssm from 'aws-cdk-lib/aws-ssm';
import { Construct } from 'constructs';
const app = new cdk.App();
// Load config from the CDK context (stored in cdk.context.json)
interface IEnvironmentConfig {
readonly scepCertificatePath: string;
readonly scepPrivateKeyPath: string;
readonly scepChallengePassword: string;
readonly mdmApiPassword: string;
readonly mdmApnsTopic: string;
}
const environment: string = process.env.ENV_NAME || 'local';
const environmentConfig: IEnvironmentConfig = app.node.tryGetContext(environment);
interface MDMStackProps extends cdk.StackProps {
envConfig: IEnvironmentConfig
}
class MDMStack extends cdk.Stack {
constructor(scope: Construct, id: string, props: MDMStackProps ) {
super(scope, id, props);
// Shared infrastructure constructs (VPC, EFS Filesystem)
const infra = new SharedInfraStack(app, 'SharedInfraStack');
// Launch SCEP server stack
const scepServer = new SCEPServerStack(app, 'SCEPServerStack', {
vpc: infra.vpc,
certificatePath: props.envConfig.scepCertificatePath,
privateKeyPath: props.envConfig.scepPrivateKeyPath,
challengePassword: props.envConfig.scepChallengePassword,
});
// Launch MDM server stack
const mdmServer = new MDMServerStack(app, 'MDMServerStack', {
vpc: infra.vpc,
apiPassword: props.envConfig.mdmApiPassword,
certificatePath: props.envConfig.scepCertificatePath,
});
// Retrieve the SCEP and MDM server URL values so that we can pass them to the Profile generator
// NOTE: valueFromLookup() will get the value _at synthesis time_, which is important for us.
// If we used valueForStringParameter() it would use a placeholder token, which would fail because
// we're using these values in the profile config.
const mdmServerUrl = ssm.StringParameter.valueFromLookup(this, '/mdmServerStack/serverUrl')
const scepServerUrl = ssm.StringParameter.valueFromLookup(this, '/scepServerStack/serverUrl')
//Deploy the MDM profile
const mdmProfileServer = new MDMProfileServerStack(app, 'MDMProfileServerStack', {
scepServerUrl: scepServerUrl,
scepChallengePassword: props.envConfig.scepChallengePassword,
mdmServerUrl: mdmServerUrl,
mdmApnsTopic: props.envConfig.mdmApnsTopic,
})
}
}
new MDMStack(app, 'MDMStack', {
envConfig: environmentConfig,
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
}
})