This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edbebc8
commit 7a5cc81
Showing
1 changed file
with
25 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,26 +25,26 @@ export class SnykTagMonitor extends GuStack { | |
new EmailSubscription('[email protected]'), | ||
); | ||
|
||
const metricProps: MetricProps = { | ||
namespace: 'snyk-tag-monitor', | ||
metricName: 'snykTagCount', | ||
dimensionsMap: { | ||
'stage': this.stage | ||
}, | ||
period: Duration.days(1), | ||
statistic: "Minimum" | ||
} | ||
const tagMetric = new Metric(metricProps) | ||
const metricProps: MetricProps = { | ||
namespace: 'snyk-tag-monitor', | ||
metricName: 'snykTagCount', | ||
dimensionsMap: { | ||
stage: this.stage, | ||
}, | ||
period: Duration.days(1), | ||
statistic: 'Minimum', | ||
}; | ||
const tagMetric = new Metric(metricProps); | ||
|
||
const tagAlarmProps: GuAlarmProps = { | ||
comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD, | ||
threshold: 4500, | ||
evaluationPeriods: 1, | ||
snsTopicName: topic.topicName, | ||
metric: tagMetric, | ||
app: app, | ||
} | ||
const tagAlarm = new GuAlarm(this, `${app}-alarm`, tagAlarmProps) | ||
const tagAlarmProps: GuAlarmProps = { | ||
comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD, | ||
threshold: 4500, | ||
evaluationPeriods: 1, | ||
snsTopicName: topic.topicName, | ||
metric: tagMetric, | ||
app: app, | ||
}; | ||
const tagAlarm = new GuAlarm(this, `${app}-alarm`, tagAlarmProps); | ||
|
||
const lambdaProps: GuScheduledLambdaProps = { | ||
rules: [{ schedule: Schedule.rate(Duration.days(7)) }], | ||
|
@@ -60,13 +60,15 @@ export class SnykTagMonitor extends GuStack { | |
SNS_TOPIC_ARN: topic.topicArn, | ||
}, | ||
timeout: Duration.minutes(5), | ||
retryAttempts: 1 | ||
retryAttempts: 1, | ||
}; | ||
|
||
const lambda = new GuScheduledLambda(this, app, lambdaProps); | ||
topic.grantPublish(lambda); | ||
const policyStatement = new PolicyStatement({actions: ['cloudwatch:PutMetricData'], resources: ['*']}) | ||
lambda.addToRolePolicy(policyStatement) | ||
|
||
const policyStatement = new PolicyStatement({ | ||
actions: ['cloudwatch:PutMetricData'], | ||
resources: ['*'], | ||
}); | ||
lambda.addToRolePolicy(policyStatement); | ||
} | ||
} |