Skip to content

Instantly share code, notes, and snippets.

import { Duration } from "aws-cdk-lib";
if (stage.valueAsString === 'CODE') {
new GuAlarm(this, 'LatencyScalingAlarm', {
app,
metricName: 'Latency',
namespace: 'AWS/ELB',
dimensions: {
LoadBalancerName: lb.loadBalancerName,
},
@ParisaTork
ParisaTork / Backend5xxAlarm.ts
Last active August 10, 2023 08:44
Backend5xxAlarm.ts
import { GuAlarm, GuStack } from '@guardian/cdk';
import { Metric, ComparisonOperator } from '@aws-cdk/aws-cloudwatch';
const Backend5XXAlarmThreshold = 100;
const Backend5XXAlarmPeriod = 1;
const Backend5XXConsecutivePeriod = 5;
const criticalAlertsTopic = sns.Topic.fromTopicArn(this, 'CriticalAlertsTopic', 'arn:aws:sns:<region>:<account-id>:Frontend-PROD-CriticalAlerts'); // modify to CODE in the meantime? I don't think we have one for CODE, so we may need to set this up
const alarm = new GuAlarm(stack, 'Backend5xxAlarm', {
@ParisaTork
ParisaTork / internalLoadBalancer.ts
Created August 3, 2023 21:52
internalLoadBalancer.ts
import { GuClassicLoadBalancer } from '@guardian/cdk';
const lb = new GuClassicLoadBalancer(stack, 'InternalLoadBalancer', {
app: 'rendering',
stack: 'frontend',
stage: 'CODE',
vpc: stack.vpc,
scheme: elb.LoadBalancerScheme.INTERNAL,
loadBalancerName: `${stack}-${stage}-${app}-ELB`,
listeners: [{
// Docs: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.InstanceProfile.html
// Sample: https://github.com/aws/aws-cdk/blob/03c6f6fb667a1d7034537b514103215bb949a8da/packages/aws-cdk-lib/aws-ec2/README.md?plain=1#L1870
// add to ts cdk file
import { InstanceProfile } from 'aws-cdk-lib/aws-iam';
const instanceProfile = new InstanceProfile(this, 'InstanceProfile', {
role: instanceRole
});