Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x | /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch"; import * as cw_actions from "aws-cdk-lib/aws-cloudwatch-actions"; import { IFunction } from "aws-cdk-lib/aws-lambda"; import * as sns from "aws-cdk-lib/aws-sns"; import { Duration, Stack } from "aws-cdk-lib"; import { Construct } from "constructs"; import { ServiceDashboard } from "./service-dashboard"; export interface ApiServiceDashboardProps { serviceName: string; apiName: string; functionName: string; objectsTableName: string; rulesTableName: string; ruleBundlesTableName: string; auditsTableName: string; schedulerFunction: IFunction; alarmsTriggerDuration: Duration; solutionOperationalTopic: sns.ITopic; canaryName?: string; } export class ApiServiceDashboard extends Construct { public dashboard: ServiceDashboard; constructor(scope: Construct, id: string, props: ApiServiceDashboardProps) { super(scope, id); const SCHEDULER_FRIENDLY_NAME = "firewall-object-rule-scheduler"; this.dashboard = new ServiceDashboard(this, "service-dashboard", { dashboardName: `RuleExtensionServiceDashboard${Stack.of(this).region}`, apiGateway: { apiName: props.apiName, endpoints: [ { method: "GET", resource: "/audits" }, { method: "POST", resource: "/objects" }, { method: "GET", resource: "/objects" }, { method: "GET", resource: "/objects/{id}" }, { method: "PUT", resource: "/objects/{id}" }, { method: "POST", resource: "/rulebundles" }, { method: "GET", resource: "/rulebundles" }, { method: "PUT", resource: "/rulebundles/{id}" }, { method: "GET", resource: "/rulebundles/{id}" }, { method: "POST", resource: "/rulebundles/{id}/rules" }, { method: "GET", resource: "/rulebundles/{id}/rules" }, { method: "GET", resource: "/rulebundles/{id}/rules/{ruleId}" }, { method: "PUT", resource: "/rulebundles/{id}/rules/{ruleId}" }, { method: "DELETE", resource: "/rulebundles/{id}/rules/{ruleId}" }, ], }, serviceName: props.serviceName, lambdas: [ { functionName: props.functionName, friendlyName: "firewall-object-rule-api", }, { functionName: props.schedulerFunction.functionName, friendlyName: SCHEDULER_FRIENDLY_NAME, }, ], dynamoDbTables: [ { tableName: props.objectsTableName, friendlyTableName: "Objects", }, { tableName: props.auditsTableName, friendlyTableName: "Audits", }, { tableName: props.rulesTableName, friendlyTableName: "Rules", }, { tableName: props.ruleBundlesTableName, friendlyTableName: "RuleBundles", }, ], }); // alarm if no error happens on remote const errorAlarm = props.schedulerFunction .metricErrors({ period: props.alarmsTriggerDuration }) .createAlarm(this, "Error-Alarm", { threshold: 1, evaluationPeriods: 2, comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD, alarmDescription: "Too many error on scheduler", }); // alarm if no invoke at all in the max configuration period const noInvocationAlarm = props.schedulerFunction .metricInvocations({ period: Duration.minutes(60) }) .createAlarm(this, "Non-Invocation-Alarm", { threshold: 1, comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD, evaluationPeriods: 1, }); noInvocationAlarm.addAlarmAction( new cw_actions.SnsAction(props.solutionOperationalTopic) ); errorAlarm.addAlarmAction( new cw_actions.SnsAction(props.solutionOperationalTopic) ); } } |