-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs-awesome-pipeline-stack.ts
41 lines (35 loc) · 1.3 KB
/
ecs-awesome-pipeline-stack.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
import * as cdk from '@aws-cdk/core';
import * as ecs from "@aws-cdk/aws-ecs";
import * as ecs_patterns from "@aws-cdk/aws-ecs-patterns";
import ecr = require("@aws-cdk/aws-ecr");
import { CfnOutput } from '@aws-cdk/core';
const COLOR = "black";
interface EcsAwesomePipelineStackProps extends cdk.StackProps {
ecsCluster: ecs.Cluster,
ecrRepository: ecr.Repository,
}
export class EcsAwesomePipelineStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: EcsAwesomePipelineStackProps) {
super(scope, id, props);
// Create a load-balanced Fargate service and make it public
const service = new ecs_patterns.ApplicationLoadBalancedFargateService(this, "MyFargateService", {
cluster: props.ecsCluster, // Required
cpu: 256, // Default is 256
desiredCount: 1, // Default is 1
taskImageOptions: {
image: ecs.ContainerImage.fromEcrRepository(props.ecrRepository, "latest"),
environment: {
COLOR
}
},
memoryLimitMiB: 512, // Default is 512
publicLoadBalancer: true // Default is false
});
new CfnOutput(this, 'LoadBalancerDNSName', {
value: service.loadBalancer.loadBalancerDnsName,
});
new CfnOutput(this, 'LoadBalancerARN', {
value: service.loadBalancer.loadBalancerArn,
});
}
}