in eventbridge-integration-solution-aws-api-cdk/lib/ecs-stack.ts [27:58]
constructor(scope: cdk.App, id: string, props: EcsProperties) {
super(scope, id, props);
const cluster = new ecs.Cluster(this, 'EventsCluster', {
vpc: props.vpc
});
const service = new ecs_patterns.ApplicationLoadBalancedFargateService(this, 'EventsService', {
cluster: cluster,
cpu: 1024,
memoryLimitMiB: 2048,
desiredCount: 3,
publicLoadBalancer: true,
taskImageOptions: {
image: ecs.ContainerImage.fromEcrRepository(props.repository, 'latest'),
containerPort: 8080,
environment: {
'spring.data.mongodb.uri': props.documentDBUri
},
},
});
props.repository.grantPull(service.taskDefinition.taskRole);
service.targetGroup.configureHealthCheck({
path: '/health'
});
const securityGroup = ec2.SecurityGroup.fromSecurityGroupId(this, 'EventsDBSecurityGroup', props.dbSecurityGroupId);
securityGroup.connections.allowFrom(service.service, ec2.Port.tcp(27017));
this.loadBalancer = service.loadBalancer;
}