Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new Alarm(this, 'TargetGroup5xx', {
metric: tg1.metricHttpCodeTarget(HttpCodeTarget.TARGET_5XX_COUNT),
threshold: 1,
evaluationPeriods: 1,
period: cdk.Duration.minutes(1)
});
new Alarm(this, 'TargetGroup2UnhealthyHosts', {
metric: tg2.metricUnhealthyHostCount(),
threshold: 1,
evaluationPeriods: 2,
});
new Alarm(this, 'TargetGroup25xx', {
metric: tg2.metricHttpCodeTarget(HttpCodeTarget.TARGET_5XX_COUNT),
threshold: 1,
evaluationPeriods: 1,
period: cdk.Duration.minutes(1)
});
// Roles
new Role(this, 'ServiceTaskDefExecutionRole', {
assumedBy: new ServicePrincipal('ecs-tasks.amazonaws.com'),
managedPolicies: [ ManagedPolicy.fromAwsManagedPolicyName('service-role/AmazonECSTaskExecutionRolePolicy') ]
});
new Role(this, 'ServiceTaskDefTaskRole', {
assumedBy: new ServicePrincipal('ecs-tasks.amazonaws.com'),
});
new Role(this, 'CodeDeployRole', {
healthyHttpCodes: '200',
healthyThresholdCount: 2,
unhealthyThresholdCount: 3,
timeout: cdk.Duration.seconds(4)
}
});
// Alarms: monitor 500s and unhealthy hosts on target groups
new Alarm(this, 'TargetGroupUnhealthyHosts', {
metric: tg1.metricUnhealthyHostCount(),
threshold: 1,
evaluationPeriods: 2,
});
new Alarm(this, 'TargetGroup5xx', {
metric: tg1.metricHttpCodeTarget(HttpCodeTarget.TARGET_5XX_COUNT),
threshold: 1,
evaluationPeriods: 1,
period: cdk.Duration.minutes(1)
});
new Alarm(this, 'TargetGroup2UnhealthyHosts', {
metric: tg2.metricUnhealthyHostCount(),
threshold: 1,
evaluationPeriods: 2,
});
new Alarm(this, 'TargetGroup25xx', {
metric: tg2.metricHttpCodeTarget(HttpCodeTarget.TARGET_5XX_COUNT),
threshold: 1,
evaluationPeriods: 1,
period: cdk.Duration.minutes(1)