forked from arhs/spikeseed-cloud-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_4.js
47 lines (42 loc) · 1.15 KB
/
app_4.js
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
const cdk = require('@aws-cdk/core')
const ec2 = require("@aws-cdk/aws-ec2")
const elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2')
class VpcStack extends cdk.Stack {
constructor(scope, id, props) {
super(scope, id, props)
this.vpc = new ec2.Vpc(this, 'VPC', {
cidr: '10.128.0.0/16',
natGateways: 1,
maxAZs: 2,
subnetConfiguration: [
{
cidrMask: 24,
name: 'Web',
subnetType: ec2.SubnetType.PUBLIC
},
{
cidrMask: 24,
name: 'Application',
subnetType: ec2.SubnetType.PRIVATE
},
{
cidrMask: 24,
name: 'Database',
subnetType: ec2.SubnetType.ISOLATED
}
]
})
}
}
class AlbStack extends cdk.Stack {
constructor(scope, id, vpcStack, props) {
super(scope, id, props)
new elbv2.ApplicationLoadBalancer(this, 'LB', {
vpc: vpcStack.vpc,
internetFacing: true
})
}
}
const app = new cdk.App()
const vpcStack = new VpcStack(app, 'VpcStack')
new AlbStack(app, 'AlbStack', vpcStack)