Created
June 19, 2021 14:19
-
-
Save leegilmorecode/fdc56a316a43cfc7a61c6834d4b8bb64 to your computer and use it in GitHub Desktop.
Bespoke IaC configuration depending on stage being deployed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { config } from "@shared/config"; | |
import { Stages } from "@models/Stages"; | |
import hello from "@functions/hello"; | |
export const configureAlarms = () => { | |
// only add alarm if prod or staging | |
if (config.stage === Stages.prod || config.stage === Stages.staging) { | |
return { | |
HelloFunctionErrorAlarm: { | |
Type: "AWS::CloudWatch::Alarm", | |
Properties: { | |
AlarmName: "HelloFunctionErrorAlarm", | |
AlarmDescription: "Alarm if lambda errors more than threshold", | |
Namespace: "AWS/Lambda", | |
MetricName: "Errors", | |
Dimensions: [ | |
{ | |
Name: "FunctionName", | |
Value: hello.name, | |
}, | |
], | |
Statistic: "Sum", | |
ComparisonOperator: "GreaterThanThreshold", | |
Threshold: 0, | |
EvaluationPeriods: 5, | |
Period: 60, | |
TreatMissingData: "breaching", | |
}, | |
}, | |
}; | |
} | |
return {}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment