-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathindex.ts
39 lines (30 loc) · 1.03 KB
/
index.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
import ec2 = require('aws-cdk-lib/aws-ec2');
import ecs = require('aws-cdk-lib/aws-ecs');
import cdk = require('aws-cdk-lib');
class WillkommenFargate extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'MyVpc', { maxAzs: 2 });
const cluster = new ecs.Cluster(this, 'Ec2Cluster', { vpc });
// create a task definition with CloudWatch Logs
const logging = new ecs.AwsLogDriver({
streamPrefix: "myapp",
})
const taskDef = new ecs.FargateTaskDefinition(this, "MyTaskDefinition", {
memoryLimitMiB: 512,
cpu: 256,
})
taskDef.addContainer("AppContainer", {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
logging,
})
// Instantiate ECS Service with just cluster and image
new ecs.FargateService(this, "FargateService", {
cluster,
taskDefinition: taskDef
});
}
}
const app = new cdk.App();
new WillkommenFargate(app, 'Willkommen');
app.synth();