diff --git a/API.md b/API.md index 8556c53..78aa407 100644 --- a/API.md +++ b/API.md @@ -2798,41 +2798,46 @@ The AWS Secrets Manager secret attached to the instance. --- -### Function +### EcsServiceCpuUtilizationAlarm -An extension of the Lambda function construct that provides methods to create recommended alarms. +This alarm is used to detect high CPU utilization for the ECS service. -#### Initializers +Consistent high CPU utilization can indicate a resource bottleneck or +application performance problems. + +The alarm is triggered when CPU utilization exceeds % threshold. + +#### Initializers ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new Function(scope: Construct, id: string, props: FunctionProps) +new EcsServiceCpuUtilizationAlarm(scope: IConstruct, id: string, props: EcsServiceCpuUtilizationAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | aws-cdk-lib.aws_lambda.FunctionProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | EcsServiceCpuUtilizationAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.Construct +- *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* aws-cdk-lib.aws_lambda.FunctionProps +- *Type:* EcsServiceCpuUtilizationAlarmProps --- @@ -2840,38 +2845,17 @@ new Function(scope: Construct, id: string, props: FunctionProps) | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addEventSource | Adds an event source to this function. | -| addEventSourceMapping | Adds an event source that maps to this AWS Lambda function. | -| addFunctionUrl | Adds a url to this lambda function. | -| addPermission | Adds a permission to the Lambda resource policy. | -| addToRolePolicy | Adds a statement to the IAM role assumed by the instance. | -| configureAsyncInvoke | Configures options for asynchronous invocation. | -| considerWarningOnInvokeFunctionPermissions | A warning will be added to functions under the following conditions: - permissions that include `lambda:InvokeFunction` are added to the unqualified function. | -| grantInvoke | Grant the given identity permissions to invoke this Lambda. | -| grantInvokeCompositePrincipal | Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. | -| grantInvokeLatestVersion | Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda. | -| grantInvokeUrl | Grant the given identity permissions to invoke this Lambda Function URL. | -| grantInvokeVersion | Grant the given identity permissions to invoke the given version of this Lambda. | -| metric | Return the given named metric for this Function. | -| metricDuration | How long execution of this Lambda takes. | -| metricErrors | How many invocations of this Lambda fail. | -| metricInvocations | How often this Lambda is invoked. | -| metricThrottles | How often this Lambda is throttled. | -| addAlias | Defines an alias for this function. | -| addEnvironment | Adds an environment variable to this Lambda function. | -| addLayers | Adds one or more Lambda Layers to this Lambda function. | -| invalidateVersionBasedOn | Mix additional information into the hash of the Version object. | -| alarmConcurrentExecutions | Creates an alarm that monitors the number of concurrent executions. | -| alarmDuration | Creates an alarm that monitors the duration of the function invocations. | -| alarmErrors | Creates an alarm that monitors the number of errors. | -| alarmThrottles | Creates an alarm that monitors the number of throttles. | -| applyRecommendedAlarms | Creates recommended alarms for the Lambda function. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -2879,7 +2863,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -2895,530 +2879,499 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addEventSource` +##### `addAlarmAction` ```typescript -public addEventSource(source: IEventSource): void +public addAlarmAction(actions: IAlarmAction): void ``` -Adds an event source to this function. - -Event sources are implemented in the aws-cdk-lib/aws-lambda-event-sources module. +Trigger this action if the alarm fires. -The following example adds an SQS Queue as an event source: -``` -import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; -myFunction.addEventSource(new SqsEventSource(myQueue)); -``` +Typically SnsAction or AutoScalingAction. -###### `source`Required +###### `actions`Required -- *Type:* aws-cdk-lib.aws_lambda.IEventSource +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addEventSourceMapping` +##### `addInsufficientDataAction` ```typescript -public addEventSourceMapping(id: string, options: EventSourceMappingOptions): EventSourceMapping +public addInsufficientDataAction(actions: IAlarmAction): void ``` -Adds an event source that maps to this AWS Lambda function. - -###### `id`Required - -- *Type:* string +Trigger this action if there is insufficient data to evaluate the alarm. ---- +Typically SnsAction or AutoScalingAction. -###### `options`Required +###### `actions`Required -- *Type:* aws-cdk-lib.aws_lambda.EventSourceMappingOptions +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addFunctionUrl` +##### `addOkAction` ```typescript -public addFunctionUrl(options?: FunctionUrlOptions): FunctionUrl +public addOkAction(actions: IAlarmAction): void ``` -Adds a url to this lambda function. +Trigger this action if the alarm returns from breaching state into ok state. -###### `options`Optional +Typically SnsAction or AutoScalingAction. -- *Type:* aws-cdk-lib.aws_lambda.FunctionUrlOptions +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addPermission` +##### `renderAlarmRule` ```typescript -public addPermission(id: string, permission: Permission): void +public renderAlarmRule(): string ``` -Adds a permission to the Lambda resource policy. +AlarmRule indicating ALARM state for Alarm. -> [Permission for details.](Permission for details.) +##### `toAnnotation` -###### `id`Required +```typescript +public toAnnotation(): HorizontalAnnotation +``` -- *Type:* string +Turn this alarm into a horizontal annotation. -The id for the permission construct. +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. ---- +This might be useful if: -###### `permission`Required +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. -- *Type:* aws-cdk-lib.aws_lambda.Permission +- You want to show an Alarm line in a graph with multiple metrics in it. -The permission to grant to this Lambda function. +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### `addToRolePolicy` +##### ~~`isConstruct`~~ ```typescript -public addToRolePolicy(statement: PolicyStatement): void +import { EcsServiceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceCpuUtilizationAlarm.isConstruct(x: any) ``` -Adds a statement to the IAM role assumed by the instance. +Checks if `x` is a construct. -###### `statement`Required +###### `x`Required -- *Type:* aws-cdk-lib.aws_iam.PolicyStatement +- *Type:* any + +Any object. --- -##### `configureAsyncInvoke` +##### `isOwnedResource` ```typescript -public configureAsyncInvoke(options: EventInvokeConfigOptions): void +import { EcsServiceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceCpuUtilizationAlarm.isOwnedResource(construct: IConstruct) ``` -Configures options for asynchronous invocation. +Returns true if the construct was created by CDK, and false otherwise. -###### `options`Required +###### `construct`Required -- *Type:* aws-cdk-lib.aws_lambda.EventInvokeConfigOptions +- *Type:* constructs.IConstruct --- -##### `considerWarningOnInvokeFunctionPermissions` +##### `isResource` ```typescript -public considerWarningOnInvokeFunctionPermissions(scope: Construct, action: string): void +import { EcsServiceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceCpuUtilizationAlarm.isResource(construct: IConstruct) ``` -A warning will be added to functions under the following conditions: - permissions that include `lambda:InvokeFunction` are added to the unqualified function. +Check whether the given construct is a Resource. -function.currentVersion is invoked before or after the permission is created. +###### `construct`Required -This applies only to permissions on Lambda functions, not versions or aliases. -This function is overridden as a noOp for QualifiedFunctionBase. +- *Type:* constructs.IConstruct -###### `scope`Required +--- + +##### `fromAlarmArn` + +```typescript +import { EcsServiceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceCpuUtilizationAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required - *Type:* constructs.Construct +The parent creating construct (usually `this`). + --- -###### `action`Required +###### `id`Required - *Type:* string ---- - -##### `grantInvoke` +The construct's name. -```typescript -public grantInvoke(grantee: IGrantable): Grant -``` +--- -Grant the given identity permissions to invoke this Lambda. +###### `alarmArn`Required -###### `grantee`Required +- *Type:* string -- *Type:* aws-cdk-lib.aws_iam.IGrantable +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `grantInvokeCompositePrincipal` +##### `fromAlarmName` ```typescript -public grantInvokeCompositePrincipal(compositePrincipal: CompositePrincipal): Grant[] +import { EcsServiceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceCpuUtilizationAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` -Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. +Import an existing CloudWatch alarm provided an Name. -###### `compositePrincipal`Required +###### `scope`Required -- *Type:* aws-cdk-lib.aws_iam.CompositePrincipal +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). --- -##### `grantInvokeLatestVersion` +###### `id`Required -```typescript -public grantInvokeLatestVersion(grantee: IGrantable): Grant -``` +- *Type:* string -Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda. +The construct's name. -###### `grantee`Required +--- -- *Type:* aws-cdk-lib.aws_iam.IGrantable +###### `alarmName`Required + +- *Type:* string + +Alarm Name. --- -##### `grantInvokeUrl` +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required ```typescript -public grantInvokeUrl(grantee: IGrantable): Grant +public readonly node: Node; ``` -Grant the given identity permissions to invoke this Lambda Function URL. - -###### `grantee`Required +- *Type:* constructs.Node -- *Type:* aws-cdk-lib.aws_iam.IGrantable +The tree node. --- -##### `grantInvokeVersion` +##### `env`Required ```typescript -public grantInvokeVersion(grantee: IGrantable, version: IVersion): Grant +public readonly env: ResourceEnvironment; ``` -Grant the given identity permissions to invoke the given version of this Lambda. +- *Type:* aws-cdk-lib.ResourceEnvironment -###### `grantee`Required +The environment this resource belongs to. -- *Type:* aws-cdk-lib.aws_iam.IGrantable +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. --- -###### `version`Required +##### `stack`Required -- *Type:* aws-cdk-lib.aws_lambda.IVersion +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. --- -##### `metric` +##### `alarmArn`Required ```typescript -public metric(metricName: string, props?: MetricOptions): Metric +public readonly alarmArn: string; ``` -Return the given named metric for this Function. - -###### `metricName`Required - - *Type:* string ---- - -###### `props`Optional - -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +ARN of this alarm. --- -##### `metricDuration` +##### `alarmName`Required ```typescript -public metricDuration(props?: MetricOptions): Metric +public readonly alarmName: string; ``` -How long execution of this Lambda takes. +- *Type:* string -Average over 5 minutes +Name of this alarm. -###### `props`Optional +--- -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions - ---- - -##### `metricErrors` - -```typescript -public metricErrors(props?: MetricOptions): Metric -``` - -How many invocations of this Lambda fail. - -Sum over 5 minutes - -###### `props`Optional - -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions - ---- - -##### `metricInvocations` +##### `metric`Required ```typescript -public metricInvocations(props?: MetricOptions): Metric +public readonly metric: IMetric; ``` -How often this Lambda is invoked. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The metric object this alarm was based on. --- -##### `metricThrottles` - -```typescript -public metricThrottles(props?: MetricOptions): Metric -``` - -How often this Lambda is throttled. -Sum over 5 minutes +### EcsServiceEphemeralStorageUtilizedAlarm -###### `props`Optional +This alarm is used to detect high ephemeral storage usage for the Fargate cluster. -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +Consistent high ephemeral storage utilized can indicate that the disk is full and it +might lead to failure of the container. ---- +The alarm is triggered when the storage utilized (GB) exceeds the threshold. -##### `addAlias` +#### Initializers ```typescript -public addAlias(aliasName: string, options?: AliasOptions): Alias -``` - -Defines an alias for this function. - -The alias will automatically be updated to point to the latest version of -the function as it is being updated during a deployment. - -```ts -declare const fn: lambda.Function; - -fn.addAlias('Live'); - -// Is equivalent to +import { EcsServiceEphemeralStorageUtilizedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new lambda.Alias(this, 'AliasLive', { - aliasName: 'Live', - version: fn.currentVersion, -}); +new EcsServiceEphemeralStorageUtilizedAlarm(scope: IConstruct, id: string, props: EcsServiceEphemeralStorageUtilizedAlarmProps) ``` -###### `aliasName`Required - -- *Type:* string - -The name of the alias. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | EcsServiceEphemeralStorageUtilizedAlarmProps | *No description.* | --- -###### `options`Optional - -- *Type:* aws-cdk-lib.aws_lambda.AliasOptions +##### `scope`Required -Alias options. +- *Type:* constructs.IConstruct --- -##### `addEnvironment` - -```typescript -public addEnvironment(key: string, value: string, options?: EnvironmentOptions): Function -``` - -Adds an environment variable to this Lambda function. - -If this is a ref to a Lambda function, this operation results in a no-op. - -###### `key`Required +##### `id`Required - *Type:* string -The environment variable key. - --- -###### `value`Required - -- *Type:* string +##### `props`Required -The environment variable's value. +- *Type:* EcsServiceEphemeralStorageUtilizedAlarmProps --- -###### `options`Optional - -- *Type:* aws-cdk-lib.aws_lambda.EnvironmentOptions +#### Methods -Environment variable options. +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `addLayers` +##### `toString` ```typescript -public addLayers(layers: ILayerVersion): void +public toString(): string ``` -Adds one or more Lambda Layers to this Lambda function. - -###### `layers`Required - -- *Type:* aws-cdk-lib.aws_lambda.ILayerVersion - -the layers to be added. - ---- +Returns a string representation of this construct. -##### `invalidateVersionBasedOn` +##### `applyRemovalPolicy` ```typescript -public invalidateVersionBasedOn(x: string): void +public applyRemovalPolicy(policy: RemovalPolicy): void ``` -Mix additional information into the hash of the Version object. - -The Lambda Function construct does its best to automatically create a new -Version when anything about the Function changes (its code, its layers, -any of the other properties). - -However, you can sometimes source information from places that the CDK cannot -look into, like the deploy-time values of SSM parameters. In those cases, -the CDK would not force the creation of a new Version object when it actually -should. +Apply the given removal policy to this resource. -This method can be used to invalidate the current Version object. Pass in -any string into this method, and make sure the string changes when you know -a new Version needs to be created. +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. -This method may be called more than once. +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `x`Required +###### `policy`Required -- *Type:* string +- *Type:* aws-cdk-lib.RemovalPolicy --- -##### `alarmConcurrentExecutions` +##### `addAlarmAction` ```typescript -public alarmConcurrentExecutions(props?: LambdaConcurrentExecutionsAlarmConfig): LambdaConcurrentExecutionsAlarm +public addAlarmAction(actions: IAlarmAction): void ``` -Creates an alarm that monitors the number of concurrent executions. +Trigger this action if the alarm fires. -###### `props`Optional +Typically SnsAction or AutoScalingAction. -- *Type:* LambdaConcurrentExecutionsAlarmConfig +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `alarmDuration` +##### `addInsufficientDataAction` ```typescript -public alarmDuration(props: LambdaDurationAlarmConfig): LambdaDurationAlarm +public addInsufficientDataAction(actions: IAlarmAction): void ``` -Creates an alarm that monitors the duration of the function invocations. +Trigger this action if there is insufficient data to evaluate the alarm. -###### `props`Required +Typically SnsAction or AutoScalingAction. -- *Type:* LambdaDurationAlarmConfig +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `alarmErrors` +##### `addOkAction` ```typescript -public alarmErrors(props: LambdaErrorsAlarmConfig): LambdaErrorsAlarm +public addOkAction(actions: IAlarmAction): void ``` -Creates an alarm that monitors the number of errors. +Trigger this action if the alarm returns from breaching state into ok state. -###### `props`Required +Typically SnsAction or AutoScalingAction. -- *Type:* LambdaErrorsAlarmConfig +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `alarmThrottles` +##### `renderAlarmRule` ```typescript -public alarmThrottles(props: LambdaThrottlesAlarmConfig): LambdaThrottlesAlarm +public renderAlarmRule(): string ``` -Creates an alarm that monitors the number of throttles. - -###### `props`Required - -- *Type:* LambdaThrottlesAlarmConfig - ---- +AlarmRule indicating ALARM state for Alarm. -##### `applyRecommendedAlarms` +##### `toAnnotation` ```typescript -public applyRecommendedAlarms(props: LambdaRecommendedAlarmsConfig): LambdaRecommendedAlarms +public toAnnotation(): HorizontalAnnotation ``` -Creates recommended alarms for the Lambda function. +Turn this alarm into a horizontal annotation. -> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda) +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. -###### `props`Required +This might be useful if: -- *Type:* LambdaRecommendedAlarmsConfig +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. ---- +- You want to show an Alarm line in a graph with multiple metrics in it. #### Static Functions | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| classifyVersionProperty | Record whether specific properties in the `AWS::Lambda::Function` resource should also be associated to the Version resource. | -| fromFunctionArn | Import a lambda function into the CDK using its ARN. | -| fromFunctionAttributes | Creates a Lambda function object which represents a function not defined within this stack. | -| fromFunctionName | Import a lambda function into the CDK using its name. | -| metricAll | Return the given named metric for this Lambda. | -| metricAllConcurrentExecutions | Metric for the number of concurrent executions across all Lambdas. | -| metricAllDuration | Metric for the Duration executing all Lambdas. | -| metricAllErrors | Metric for the number of Errors executing all Lambdas. | -| metricAllInvocations | Metric for the number of invocations of all Lambdas. | -| metricAllThrottles | Metric for the number of throttled invocations of all Lambdas. | -| metricAllUnreservedConcurrentExecutions | Metric for the number of unreserved concurrent executions across all Lambdas. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceEphemeralStorageUtilizedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Function.isConstruct(x: any) +EcsServiceEphemeralStorageUtilizedAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -3426,605 +3379,784 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceEphemeralStorageUtilizedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Function.isOwnedResource(construct: IConstruct) +EcsServiceEphemeralStorageUtilizedAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceEphemeralStorageUtilizedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Function.isResource(construct: IConstruct) +EcsServiceEphemeralStorageUtilizedAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `classifyVersionProperty` +##### `fromAlarmArn` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceEphemeralStorageUtilizedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Function.classifyVersionProperty(propertyName: string, locked: boolean) +EcsServiceEphemeralStorageUtilizedAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` -Record whether specific properties in the `AWS::Lambda::Function` resource should also be associated to the Version resource. +Import an existing CloudWatch alarm provided an ARN. -See 'currentVersion' section in the module README for more details. +###### `scope`Required -###### `propertyName`Required +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required - *Type:* string -The property to classify. +The construct's name. --- -###### `locked`Required +###### `alarmArn`Required -- *Type:* boolean +- *Type:* string -whether the property should be associated to the version or not. +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromFunctionArn` +##### `fromAlarmName` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceEphemeralStorageUtilizedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Function.fromFunctionArn(scope: Construct, id: string, functionArn: string) +EcsServiceEphemeralStorageUtilizedAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` -Import a lambda function into the CDK using its ARN. - -For `Function.addPermissions()` to work on this imported lambda, make sure that is -in the same account and region as the stack you are importing it into. +Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct +The parent creating construct (usually `this`). + --- -###### `id`Required +###### `id`Required - *Type:* string +The construct's name. + --- -###### `functionArn`Required +###### `alarmName`Required - *Type:* string ---- +Alarm Name. -##### `fromFunctionAttributes` +--- -```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +#### Properties -Function.fromFunctionAttributes(scope: Construct, id: string, attrs: FunctionAttributes) -``` +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | -Creates a Lambda function object which represents a function not defined within this stack. +--- -For `Function.addPermissions()` to work on this imported lambda, set the sameEnvironment property to true -if this imported lambda is in the same account and region as the stack you are importing it into. +##### `node`Required -###### `scope`Required +```typescript +public readonly node: Node; +``` -- *Type:* constructs.Construct +- *Type:* constructs.Node -The parent construct. +The tree node. --- -###### `id`Required - -- *Type:* string - -The name of the lambda construct. +##### `env`Required ---- +```typescript +public readonly env: ResourceEnvironment; +``` -###### `attrs`Required +- *Type:* aws-cdk-lib.ResourceEnvironment -- *Type:* aws-cdk-lib.aws_lambda.FunctionAttributes +The environment this resource belongs to. -the attributes of the function to import. +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. --- -##### `fromFunctionName` +##### `stack`Required ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Function.fromFunctionName(scope: Construct, id: string, functionName: string) +public readonly stack: Stack; ``` -Import a lambda function into the CDK using its name. - -###### `scope`Required +- *Type:* aws-cdk-lib.Stack -- *Type:* constructs.Construct +The stack in which this resource is defined. --- -###### `id`Required +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` - *Type:* string +ARN of this alarm. + --- -###### `functionName`Required +##### `alarmName`Required + +```typescript +public readonly alarmName: string; +``` - *Type:* string +Name of this alarm. + --- -##### `metricAll` +##### `metric`Required ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Function.metricAll(metricName: string, props?: MetricOptions) +public readonly metric: IMetric; ``` -Return the given named metric for this Lambda. - -###### `metricName`Required +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -- *Type:* string +The metric object this alarm was based on. --- -###### `props`Optional -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +### EcsServiceMemoryUtilizationAlarm ---- +This alarm is used to detect high memory utilization for the ECS service. -##### `metricAllConcurrentExecutions` +Consistent high memory utilization can indicate a resource bottleneck or +application performance problems. + +The alarm is triggered when memory utilization exceeds % threshold. + +#### Initializers ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceMemoryUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Function.metricAllConcurrentExecutions(props?: MetricOptions) +new EcsServiceMemoryUtilizationAlarm(scope: IConstruct, id: string, props: EcsServiceMemoryUtilizationAlarmProps) ``` -Metric for the number of concurrent executions across all Lambdas. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | EcsServiceMemoryUtilizationAlarmProps | *No description.* | -###### `props`Optional +--- -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +##### `scope`Required + +- *Type:* constructs.IConstruct --- -##### `metricAllDuration` +##### `id`Required -```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +- *Type:* string -Function.metricAllDuration(props?: MetricOptions) -``` +--- -Metric for the Duration executing all Lambdas. +##### `props`Required -###### `props`Optional +- *Type:* EcsServiceMemoryUtilizationAlarmProps -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `metricAllErrors` +##### `toString` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' +public toString(): string +``` -Function.metricAllErrors(props?: MetricOptions) +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void ``` -Metric for the number of Errors executing all Lambdas. +Apply the given removal policy to this resource. -###### `props`Optional +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy --- -##### `metricAllInvocations` +##### `addAlarmAction` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Function.metricAllInvocations(props?: MetricOptions) +public addAlarmAction(actions: IAlarmAction): void ``` -Metric for the number of invocations of all Lambdas. +Trigger this action if the alarm fires. -###### `props`Optional +Typically SnsAction or AutoScalingAction. -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `metricAllThrottles` +##### `addInsufficientDataAction` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Function.metricAllThrottles(props?: MetricOptions) +public addInsufficientDataAction(actions: IAlarmAction): void ``` -Metric for the number of throttled invocations of all Lambdas. +Trigger this action if there is insufficient data to evaluate the alarm. -###### `props`Optional +Typically SnsAction or AutoScalingAction. -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `metricAllUnreservedConcurrentExecutions` +##### `addOkAction` ```typescript -import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Function.metricAllUnreservedConcurrentExecutions(props?: MetricOptions) +public addOkAction(actions: IAlarmAction): void ``` -Metric for the number of unreserved concurrent executions across all Lambdas. +Trigger this action if the alarm returns from breaching state into ok state. -###### `props`Optional +Typically SnsAction or AutoScalingAction. -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -#### Properties +##### `renderAlarmRule` -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| architecture | aws-cdk-lib.aws_lambda.Architecture | The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64). | -| connections | aws-cdk-lib.aws_ec2.Connections | Access the Connections object. | -| functionArn | string | ARN of this function. | -| functionName | string | Name of this function. | -| grantPrincipal | aws-cdk-lib.aws_iam.IPrincipal | The principal this Lambda Function is running as. | -| isBoundToVpc | boolean | Whether or not this Lambda function was bound to a VPC. | -| latestVersion | aws-cdk-lib.aws_lambda.IVersion | The `$LATEST` version of this function. | -| permissionsNode | constructs.Node | The construct node where permissions are attached. | -| resourceArnsForGrantInvoke | string[] | The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). | -| role | aws-cdk-lib.aws_iam.IRole | Execution role associated with this function. | -| currentVersion | aws-cdk-lib.aws_lambda.Version | Returns a `lambda.Version` which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes. | -| logGroup | aws-cdk-lib.aws_logs.ILogGroup | The LogGroup where the Lambda function's logs are made available. | -| runtime | aws-cdk-lib.aws_lambda.Runtime | The runtime configured for this lambda. | -| deadLetterQueue | aws-cdk-lib.aws_sqs.IQueue | The DLQ (as queue) associated with this Lambda Function (this is an optional attribute). | -| deadLetterTopic | aws-cdk-lib.aws_sns.ITopic | The DLQ (as topic) associated with this Lambda Function (this is an optional attribute). | -| timeout | aws-cdk-lib.Duration | The timeout configured for this lambda. | +```typescript +public renderAlarmRule(): string +``` ---- +AlarmRule indicating ALARM state for Alarm. -##### `node`Required +##### `toAnnotation` ```typescript -public readonly node: Node; +public toAnnotation(): HorizontalAnnotation ``` -- *Type:* constructs.Node - -The tree node. +Turn this alarm into a horizontal annotation. ---- +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. -##### `env`Required +This might be useful if: -```typescript -public readonly env: ResourceEnvironment; -``` +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. -- *Type:* aws-cdk-lib.ResourceEnvironment +- You want to show an Alarm line in a graph with multiple metrics in it. -The environment this resource belongs to. +#### Static Functions -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### `stack`Required +##### ~~`isConstruct`~~ ```typescript -public readonly stack: Stack; +import { EcsServiceMemoryUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceMemoryUtilizationAlarm.isConstruct(x: any) ``` -- *Type:* aws-cdk-lib.Stack +Checks if `x` is a construct. -The stack in which this resource is defined. +###### `x`Required + +- *Type:* any + +Any object. --- -##### `architecture`Required +##### `isOwnedResource` ```typescript -public readonly architecture: Architecture; +import { EcsServiceMemoryUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceMemoryUtilizationAlarm.isOwnedResource(construct: IConstruct) ``` -- *Type:* aws-cdk-lib.aws_lambda.Architecture +Returns true if the construct was created by CDK, and false otherwise. -The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64). +###### `construct`Required + +- *Type:* constructs.IConstruct --- -##### `connections`Required +##### `isResource` ```typescript -public readonly connections: Connections; +import { EcsServiceMemoryUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceMemoryUtilizationAlarm.isResource(construct: IConstruct) ``` -- *Type:* aws-cdk-lib.aws_ec2.Connections +Check whether the given construct is a Resource. -Access the Connections object. +###### `construct`Required -Will fail if not a VPC-enabled Lambda Function +- *Type:* constructs.IConstruct --- -##### `functionArn`Required +##### `fromAlarmArn` ```typescript -public readonly functionArn: string; +import { EcsServiceMemoryUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceMemoryUtilizationAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + - *Type:* string -ARN of this function. +The construct's name. --- -##### `functionName`Required +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` ```typescript -public readonly functionName: string; +import { EcsServiceMemoryUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceMemoryUtilizationAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + - *Type:* string -Name of this function. +The construct's name. --- -##### `grantPrincipal`Required +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required ```typescript -public readonly grantPrincipal: IPrincipal; +public readonly node: Node; ``` -- *Type:* aws-cdk-lib.aws_iam.IPrincipal +- *Type:* constructs.Node -The principal this Lambda Function is running as. +The tree node. --- -##### `isBoundToVpc`Required +##### `env`Required ```typescript -public readonly isBoundToVpc: boolean; +public readonly env: ResourceEnvironment; ``` -- *Type:* boolean +- *Type:* aws-cdk-lib.ResourceEnvironment -Whether or not this Lambda function was bound to a VPC. +The environment this resource belongs to. -If this is is `false`, trying to access the `connections` object will fail. +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. --- -##### `latestVersion`Required +##### `stack`Required ```typescript -public readonly latestVersion: IVersion; +public readonly stack: Stack; ``` -- *Type:* aws-cdk-lib.aws_lambda.IVersion +- *Type:* aws-cdk-lib.Stack -The `$LATEST` version of this function. +The stack in which this resource is defined. -Note that this is reference to a non-specific AWS Lambda version, which -means the function this version refers to can return different results in -different invocations. +--- -To obtain a reference to an explicit version which references the current -function configuration, use `lambdaFunction.currentVersion` instead. +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` + +- *Type:* string + +ARN of this alarm. --- -##### `permissionsNode`Required +##### `alarmName`Required ```typescript -public readonly permissionsNode: Node; +public readonly alarmName: string; ``` -- *Type:* constructs.Node +- *Type:* string -The construct node where permissions are attached. +Name of this alarm. --- -##### `resourceArnsForGrantInvoke`Required +##### `metric`Required ```typescript -public readonly resourceArnsForGrantInvoke: string[]; +public readonly metric: IMetric; ``` -- *Type:* string[] +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). +The metric object this alarm was based on. --- -##### `role`Optional + +### EcsServiceRecommendedAlarms + +A construct that creates the recommended alarms for an ECS service. + +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS) + +#### Initializers ```typescript -public readonly role: IRole; +import { EcsServiceRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new EcsServiceRecommendedAlarms(scope: Construct, id: string, props: EcsServiceRecommendedAlarmsProps) ``` -- *Type:* aws-cdk-lib.aws_iam.IRole +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | EcsServiceRecommendedAlarmsProps | *No description.* | -Execution role associated with this function. +--- + +##### `scope`Required + +- *Type:* constructs.Construct --- -##### `currentVersion`Required +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* EcsServiceRecommendedAlarmsProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | + +--- + +##### `toString` ```typescript -public readonly currentVersion: Version; +public toString(): string ``` -- *Type:* aws-cdk-lib.aws_lambda.Version +Returns a string representation of this construct. -Returns a `lambda.Version` which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes. +#### Static Functions -You can specify options for this version using the `currentVersionOptions` -prop when initializing the `lambda.Function`. +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | --- -##### `logGroup`Required +##### ~~`isConstruct`~~ ```typescript -public readonly logGroup: ILogGroup; +import { EcsServiceRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +EcsServiceRecommendedAlarms.isConstruct(x: any) ``` -- *Type:* aws-cdk-lib.aws_logs.ILogGroup +Checks if `x` is a construct. -The LogGroup where the Lambda function's logs are made available. +###### `x`Required -If either `logRetention` is set or this property is called, a CloudFormation custom resource is added to the stack that -pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the correct log retention -period (never expire, by default). +- *Type:* any -Further, if the log group already exists and the `logRetention` is not set, the custom resource will reset the log retention -to never expire even if it was configured with a different value. +Any object. --- -##### `runtime`Required +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| alarmCpuUtilization | EcsServiceCpuUtilizationAlarm | The CpuUtilization alarm. | +| alarmEphemeralStorageUtilized | EcsServiceEphemeralStorageUtilizedAlarm | The EphemeralStorageUtilized alarm. | +| alarmMemoryUtilization | EcsServiceMemoryUtilizationAlarm | The MemoryUtilization alarm. | +| alarmRunningTaskCount | EcsServiceRunningTaskCountAlarm | The RunningTaskCount alarm. | + +--- + +##### `node`Required ```typescript -public readonly runtime: Runtime; +public readonly node: Node; ``` -- *Type:* aws-cdk-lib.aws_lambda.Runtime +- *Type:* constructs.Node -The runtime configured for this lambda. +The tree node. --- -##### `deadLetterQueue`Optional +##### `alarmCpuUtilization`Optional ```typescript -public readonly deadLetterQueue: IQueue; +public readonly alarmCpuUtilization: EcsServiceCpuUtilizationAlarm; ``` -- *Type:* aws-cdk-lib.aws_sqs.IQueue +- *Type:* EcsServiceCpuUtilizationAlarm -The DLQ (as queue) associated with this Lambda Function (this is an optional attribute). +The CpuUtilization alarm. --- -##### `deadLetterTopic`Optional +##### `alarmEphemeralStorageUtilized`Optional ```typescript -public readonly deadLetterTopic: ITopic; +public readonly alarmEphemeralStorageUtilized: EcsServiceEphemeralStorageUtilizedAlarm; ``` -- *Type:* aws-cdk-lib.aws_sns.ITopic +- *Type:* EcsServiceEphemeralStorageUtilizedAlarm -The DLQ (as topic) associated with this Lambda Function (this is an optional attribute). +The EphemeralStorageUtilized alarm. --- -##### `timeout`Optional +##### `alarmMemoryUtilization`Optional ```typescript -public readonly timeout: Duration; +public readonly alarmMemoryUtilization: EcsServiceMemoryUtilizationAlarm; ``` -- *Type:* aws-cdk-lib.Duration +- *Type:* EcsServiceMemoryUtilizationAlarm -The timeout configured for this lambda. +The MemoryUtilization alarm. --- +##### `alarmRunningTaskCount`Optional -### LambdaConcurrentExecutionsAlarm +```typescript +public readonly alarmRunningTaskCount: EcsServiceRunningTaskCountAlarm; +``` -This alarm can proactively detect if the concurrency of the function is approaching the Region-level concurrency quota of your account, so that you can act on it. +- *Type:* EcsServiceRunningTaskCountAlarm -A function is -throttled if it reaches the Region-level concurrency quota -of the account. +The RunningTaskCount alarm. -The alarm is triggered when the number of concurrent executions -exceeds the specified threshold. +--- -#### Initializers + +### EcsServiceRunningTaskCountAlarm + +This alarm helps you detect a low running task count of the ECS service. + +If the running task count is too low, it can can indicate that the application +can’t handle the service load and it might lead to performance issues. If there +is no running task, the Amazon ECS service might be unavailable or there might +be deployment issues. + +The alarm is triggered when the number of running tasks is less than or equal to +threshold. + +#### Initializers ```typescript -import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceRunningTaskCountAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new LambdaConcurrentExecutionsAlarm(scope: Construct, id: string, props: LambdaConcurrentExecutionsAlarmProps) +new EcsServiceRunningTaskCountAlarm(scope: IConstruct, id: string, props: EcsServiceRunningTaskCountAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | LambdaConcurrentExecutionsAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | EcsServiceRunningTaskCountAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.Construct +- *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* LambdaConcurrentExecutionsAlarmProps +- *Type:* EcsServiceRunningTaskCountAlarmProps --- @@ -4032,17 +4164,17 @@ new LambdaConcurrentExecutionsAlarm(scope: Construct, id: string, props: LambdaC | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -4050,7 +4182,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -4066,13 +4198,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -4082,13 +4214,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -4098,13 +4230,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -4114,13 +4246,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -4128,7 +4260,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -4153,25 +4285,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceRunningTaskCountAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaConcurrentExecutionsAlarm.isConstruct(x: any) +EcsServiceRunningTaskCountAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -4179,49 +4311,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceRunningTaskCountAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaConcurrentExecutionsAlarm.isOwnedResource(construct: IConstruct) +EcsServiceRunningTaskCountAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceRunningTaskCountAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaConcurrentExecutionsAlarm.isResource(construct: IConstruct) +EcsServiceRunningTaskCountAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceRunningTaskCountAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaConcurrentExecutionsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +EcsServiceRunningTaskCountAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -4229,7 +4361,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -4237,7 +4369,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -4245,17 +4377,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceRunningTaskCountAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaConcurrentExecutionsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +EcsServiceRunningTaskCountAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -4263,7 +4395,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -4271,7 +4403,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -4283,16 +4415,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -4304,7 +4436,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -4323,7 +4455,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -4335,7 +4467,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -4347,7 +4479,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -4359,7 +4491,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -4372,51 +4504,41 @@ The metric object this alarm was based on. --- -### LambdaDurationAlarm - -This alarm can detect a long running duration of a Lambda function. - -High runtime duration indicates that -a function is taking a longer time for invocation, and -can also impact the concurrency capacity of invocation -if Lambda is handling a higher number of events. It is -critical to know if the Lambda function is constantly -taking longer execution time than expected. +### FargateService -The alarm is triggered when the duration of the function -invocations exceeds the specified threshold. +An extension for the FargateService construct that provides methods to create recommended alarms. -#### Initializers +#### Initializers ```typescript -import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { FargateService } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new LambdaDurationAlarm(scope: Construct, id: string, props: LambdaDurationAlarmProps) +new FargateService(scope: Construct, id: string, props: FargateServiceProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | LambdaDurationAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | aws-cdk-lib.aws_ecs.FargateServiceProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* LambdaDurationAlarmProps +- *Type:* aws-cdk-lib.aws_ecs.FargateServiceProps --- @@ -4424,17 +4546,31 @@ new LambdaDurationAlarm(scope: Construct, id: string, props: LambdaDurationAlarm | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | - ---- - -##### `toString` +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addVolume | Adds a volume to the Service. | +| associateCloudMapService | Associates this service with a CloudMap service. | +| attachToApplicationTargetGroup | This method is called to attach this service to an Application Load Balancer. | +| attachToClassicLB | Registers the service as a target of a Classic Load Balancer (CLB). | +| attachToNetworkTargetGroup | This method is called to attach this service to a Network Load Balancer. | +| autoScaleTaskCount | An attribute representing the minimum and maximum task count for an AutoScalingGroup. | +| enableCloudMap | Enable CloudMap service discovery for the service. | +| enableDeploymentAlarms | Enable Deployment Alarms which take advantage of arbitrary alarms and configure them after service initialization. | +| enableServiceConnect | Enable Service Connect on this service. | +| loadBalancerTarget | Return a load balancing target for a specific container and port. | +| metric | This method returns the specified CloudWatch metric name for this service. | +| metricCpuUtilization | This method returns the CloudWatch metric for this service's CPU utilization. | +| metricMemoryUtilization | This method returns the CloudWatch metric for this service's memory utilization. | +| registerLoadBalancerTargets | Use this function to create all load balancer targets to be registered in this service, add them to target groups, and attach target groups to listeners accordingly. | +| alarmCpuUtilization | Creates an alarm that monitors the CPU utilization for the Fargate service. | +| alarmEphemeralStorageUtilized | Creates an alarm that monitors the ephemeral storage utilized for the Fargate service. | +| alarmMemoryUtilization | Creates an alarm that monitors the memory utilization for the Fargate service. | +| alarmRunningTaskCount | Creates an alarm that monitors the number of task running. | +| applyRecommendedAlarms | Creates the recommended alarms for the ECS service. | + +--- + +##### `toString` ```typescript public toString(): string @@ -4442,7 +4578,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -4458,601 +4594,503 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addVolume` ```typescript -public addAlarmAction(actions: IAlarmAction): void +public addVolume(volume: ServiceManagedVolume): void ``` -Trigger this action if the alarm fires. - -Typically SnsAction or AutoScalingAction. +Adds a volume to the Service. -###### `actions`Required +###### `volume`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* aws-cdk-lib.aws_ecs.ServiceManagedVolume --- -##### `addInsufficientDataAction` +##### `associateCloudMapService` ```typescript -public addInsufficientDataAction(actions: IAlarmAction): void +public associateCloudMapService(options: AssociateCloudMapServiceOptions): void ``` -Trigger this action if there is insufficient data to evaluate the alarm. - -Typically SnsAction or AutoScalingAction. +Associates this service with a CloudMap service. -###### `actions`Required +###### `options`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* aws-cdk-lib.aws_ecs.AssociateCloudMapServiceOptions --- -##### `addOkAction` +##### `attachToApplicationTargetGroup` ```typescript -public addOkAction(actions: IAlarmAction): void +public attachToApplicationTargetGroup(targetGroup: IApplicationTargetGroup): LoadBalancerTargetProps ``` -Trigger this action if the alarm returns from breaching state into ok state. +This method is called to attach this service to an Application Load Balancer. -Typically SnsAction or AutoScalingAction. +Don't call this function directly. Instead, call `listener.addTargets()` +to add this service to a load balancer. -###### `actions`Required +###### `targetGroup`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* aws-cdk-lib.aws_elasticloadbalancingv2.IApplicationTargetGroup --- -##### `renderAlarmRule` - -```typescript -public renderAlarmRule(): string -``` - -AlarmRule indicating ALARM state for Alarm. - -##### `toAnnotation` +##### `attachToClassicLB` ```typescript -public toAnnotation(): HorizontalAnnotation +public attachToClassicLB(loadBalancer: LoadBalancer): void ``` -Turn this alarm into a horizontal annotation. - -This is useful if you want to represent an Alarm in a non-AlarmWidget. -An `AlarmWidget` can directly show an alarm, but it can only show a -single alarm and no other metrics. Instead, you can convert the alarm to -a HorizontalAnnotation and add it as an annotation to another graph. - -This might be useful if: - -- You want to show multiple alarms inside a single graph, for example if - you have both a "small margin/long period" alarm as well as a - "large margin/short period" alarm. +Registers the service as a target of a Classic Load Balancer (CLB). -- You want to show an Alarm line in a graph with multiple metrics in it. +Don't call this. Call `loadBalancer.addTarget()` instead. -#### Static Functions +###### `loadBalancer`Required -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +- *Type:* aws-cdk-lib.aws_elasticloadbalancing.LoadBalancer --- -##### ~~`isConstruct`~~ +##### `attachToNetworkTargetGroup` ```typescript -import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -LambdaDurationAlarm.isConstruct(x: any) +public attachToNetworkTargetGroup(targetGroup: INetworkTargetGroup): LoadBalancerTargetProps ``` -Checks if `x` is a construct. +This method is called to attach this service to a Network Load Balancer. -###### `x`Required +Don't call this function directly. Instead, call `listener.addTargets()` +to add this service to a load balancer. -- *Type:* any +###### `targetGroup`Required -Any object. +- *Type:* aws-cdk-lib.aws_elasticloadbalancingv2.INetworkTargetGroup --- -##### `isOwnedResource` +##### `autoScaleTaskCount` ```typescript -import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -LambdaDurationAlarm.isOwnedResource(construct: IConstruct) +public autoScaleTaskCount(props: EnableScalingProps): ScalableTaskCount ``` -Returns true if the construct was created by CDK, and false otherwise. +An attribute representing the minimum and maximum task count for an AutoScalingGroup. -###### `construct`Required +###### `props`Required -- *Type:* constructs.IConstruct +- *Type:* aws-cdk-lib.aws_applicationautoscaling.EnableScalingProps --- -##### `isResource` +##### `enableCloudMap` ```typescript -import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -LambdaDurationAlarm.isResource(construct: IConstruct) +public enableCloudMap(options: CloudMapOptions): Service ``` -Check whether the given construct is a Resource. +Enable CloudMap service discovery for the service. -###### `construct`Required +###### `options`Required -- *Type:* constructs.IConstruct +- *Type:* aws-cdk-lib.aws_ecs.CloudMapOptions --- -##### `fromAlarmArn` +##### `enableDeploymentAlarms` ```typescript -import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -LambdaDurationAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +public enableDeploymentAlarms(alarmNames: string[], options?: DeploymentAlarmOptions): void ``` -Import an existing CloudWatch alarm provided an ARN. +Enable Deployment Alarms which take advantage of arbitrary alarms and configure them after service initialization. -###### `scope`Required +If you have already enabled deployment alarms, this function can be used to tell ECS about additional alarms that +should interrupt a deployment. -- *Type:* constructs.Construct +New alarms specified in subsequent calls of this function will be appended to the existing list of alarms. -The parent creating construct (usually `this`). +The same Alarm Behavior must be used on all deployment alarms. If you specify different AlarmBehavior values in +multiple calls to this function, or the Alarm Behavior used here doesn't match the one used in the service +constructor, an error will be thrown. ---- +If the alarm's metric references the service, you cannot pass `Alarm.alarmName` here. That will cause a circular +dependency between the service and its deployment alarm. See this package's README for options to alarm on service +metrics, and avoid this circular dependency. -###### `id`Required +###### `alarmNames`Required -- *Type:* string +- *Type:* string[] -The construct's name. +--- + +###### `options`Optional + +- *Type:* aws-cdk-lib.aws_ecs.DeploymentAlarmOptions --- -###### `alarmArn`Required +##### `enableServiceConnect` -- *Type:* string +```typescript +public enableServiceConnect(config?: ServiceConnectProps): void +``` -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). +Enable Service Connect on this service. + +###### `config`Optional + +- *Type:* aws-cdk-lib.aws_ecs.ServiceConnectProps --- -##### `fromAlarmName` +##### `loadBalancerTarget` ```typescript -import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -LambdaDurationAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +public loadBalancerTarget(options: LoadBalancerTargetOptions): IEcsLoadBalancerTarget ``` -Import an existing CloudWatch alarm provided an Name. +Return a load balancing target for a specific container and port. -###### `scope`Required +Use this function to create a load balancer target if you want to load balance to +another container than the first essential container or the first mapped port on +the container. -- *Type:* constructs.Construct +Use the return value of this function where you would normally use a load balancer +target, instead of the `Service` object itself. -The parent creating construct (usually `this`). +*Example* ---- +```typescript +declare const listener: elbv2.ApplicationListener; +declare const service: ecs.BaseService; +listener.addTargets('ECS', { + port: 80, + targets: [service.loadBalancerTarget({ + containerName: 'MyContainer', + containerPort: 1234, + })], +}); +``` -###### `id`Required -- *Type:* string +###### `options`Required -The construct's name. +- *Type:* aws-cdk-lib.aws_ecs.LoadBalancerTargetOptions --- -###### `alarmName`Required +##### `metric` -- *Type:* string +```typescript +public metric(metricName: string, props?: MetricOptions): Metric +``` -Alarm Name. +This method returns the specified CloudWatch metric name for this service. + +###### `metricName`Required + +- *Type:* string --- -#### Properties +###### `props`Optional -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `node`Required +##### `metricCpuUtilization` ```typescript -public readonly node: Node; +public metricCpuUtilization(props?: MetricOptions): Metric ``` -- *Type:* constructs.Node +This method returns the CloudWatch metric for this service's CPU utilization. -The tree node. +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `env`Required +##### `metricMemoryUtilization` ```typescript -public readonly env: ResourceEnvironment; +public metricMemoryUtilization(props?: MetricOptions): Metric ``` -- *Type:* aws-cdk-lib.ResourceEnvironment +This method returns the CloudWatch metric for this service's memory utilization. -The environment this resource belongs to. +###### `props`Optional -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `stack`Required +##### `registerLoadBalancerTargets` ```typescript -public readonly stack: Stack; +public registerLoadBalancerTargets(targets: EcsTarget): void ``` -- *Type:* aws-cdk-lib.Stack - -The stack in which this resource is defined. +Use this function to create all load balancer targets to be registered in this service, add them to target groups, and attach target groups to listeners accordingly. ---- +Alternatively, you can use `listener.addTargets()` to create targets and add them to target groups. -##### `alarmArn`Required +*Example* ```typescript -public readonly alarmArn: string; +declare const listener: elbv2.ApplicationListener; +declare const service: ecs.BaseService; +service.registerLoadBalancerTargets( + { + containerName: 'web', + containerPort: 80, + newTargetGroupId: 'ECS', + listener: ecs.ListenerConfig.applicationListener(listener, { + protocol: elbv2.ApplicationProtocol.HTTPS + }), + }, +) ``` -- *Type:* string -ARN of this alarm. +###### `targets`Required + +- *Type:* aws-cdk-lib.aws_ecs.EcsTarget --- -##### `alarmName`Required +##### `alarmCpuUtilization` ```typescript -public readonly alarmName: string; +public alarmCpuUtilization(props?: EcsCpuUtilizationAlarmConfig): EcsServiceCpuUtilizationAlarm ``` -- *Type:* string +Creates an alarm that monitors the CPU utilization for the Fargate service. -Name of this alarm. +###### `props`Optional + +- *Type:* EcsCpuUtilizationAlarmConfig --- -##### `metric`Required +##### `alarmEphemeralStorageUtilized` ```typescript -public readonly metric: IMetric; +public alarmEphemeralStorageUtilized(props: EcsEphemeralStorageUtilizedAlarmConfig): EcsServiceEphemeralStorageUtilizedAlarm ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +Creates an alarm that monitors the ephemeral storage utilized for the Fargate service. -The metric object this alarm was based on. +###### `props`Required + +- *Type:* EcsEphemeralStorageUtilizedAlarmConfig --- +##### `alarmMemoryUtilization` -### LambdaErrorsAlarm +```typescript +public alarmMemoryUtilization(props?: EcsMemoryUtilizationAlarmConfig): EcsServiceMemoryUtilizationAlarm +``` -The alarm helps detect high error counts in function invocations. +Creates an alarm that monitors the memory utilization for the Fargate service. -The alarm is triggered when the number of errors exceeds the specified -threshold. +###### `props`Optional -#### Initializers +- *Type:* EcsMemoryUtilizationAlarmConfig -```typescript -import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +--- -new LambdaErrorsAlarm(scope: Construct, id: string, props: LambdaErrorsAlarmProps) -``` +##### `alarmRunningTaskCount` -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | LambdaErrorsAlarmProps | *No description.* | +```typescript +public alarmRunningTaskCount(props?: EcsRunningTaskCountAlarmConfig): EcsServiceRunningTaskCountAlarm +``` ---- +Creates an alarm that monitors the number of task running. -##### `scope`Required +###### `props`Optional -- *Type:* constructs.Construct +- *Type:* EcsRunningTaskCountAlarmConfig --- -##### `id`Required +##### `applyRecommendedAlarms` -- *Type:* string +```typescript +public applyRecommendedAlarms(props: EcsServiceRecommendedAlarmsConfig): EcsServiceRecommendedAlarms +``` ---- +Creates the recommended alarms for the ECS service. -##### `props`Required +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS) -- *Type:* LambdaErrorsAlarmProps +###### `props`Required + +- *Type:* EcsServiceRecommendedAlarmsConfig --- -#### Methods +#### Static Functions | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromServiceArnWithCluster | Import an existing ECS/Fargate Service using the service cluster format. | +| fromFargateServiceArn | Imports from the specified service ARN. | +| fromFargateServiceAttributes | Imports from the specified service attributes. | --- -##### `toString` - -```typescript -public toString(): string -``` - -Returns a string representation of this construct. - -##### `applyRemovalPolicy` +##### ~~`isConstruct`~~ ```typescript -public applyRemovalPolicy(policy: RemovalPolicy): void -``` - -Apply the given removal policy to this resource. - -The Removal Policy controls what happens to this resource when it stops -being managed by CloudFormation, either because you've removed it from the -CDK application or because you've made a change that requires the resource -to be replaced. - -The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS -account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). - -###### `policy`Required - -- *Type:* aws-cdk-lib.RemovalPolicy - ---- - -##### `addAlarmAction` +import { FargateService } from '@renovosolutions/cdk-library-cloudwatch-alarms' -```typescript -public addAlarmAction(actions: IAlarmAction): void +FargateService.isConstruct(x: any) ``` -Trigger this action if the alarm fires. +Checks if `x` is a construct. -Typically SnsAction or AutoScalingAction. +###### `x`Required -###### `actions`Required +- *Type:* any -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +Any object. --- -##### `addInsufficientDataAction` +##### `isOwnedResource` ```typescript -public addInsufficientDataAction(actions: IAlarmAction): void -``` - -Trigger this action if there is insufficient data to evaluate the alarm. - -Typically SnsAction or AutoScalingAction. - -###### `actions`Required - -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction - ---- - -##### `addOkAction` +import { FargateService } from '@renovosolutions/cdk-library-cloudwatch-alarms' -```typescript -public addOkAction(actions: IAlarmAction): void +FargateService.isOwnedResource(construct: IConstruct) ``` -Trigger this action if the alarm returns from breaching state into ok state. - -Typically SnsAction or AutoScalingAction. +Returns true if the construct was created by CDK, and false otherwise. -###### `actions`Required +###### `construct`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* constructs.IConstruct --- -##### `renderAlarmRule` +##### `isResource` ```typescript -public renderAlarmRule(): string -``` - -AlarmRule indicating ALARM state for Alarm. - -##### `toAnnotation` +import { FargateService } from '@renovosolutions/cdk-library-cloudwatch-alarms' -```typescript -public toAnnotation(): HorizontalAnnotation +FargateService.isResource(construct: IConstruct) ``` -Turn this alarm into a horizontal annotation. - -This is useful if you want to represent an Alarm in a non-AlarmWidget. -An `AlarmWidget` can directly show an alarm, but it can only show a -single alarm and no other metrics. Instead, you can convert the alarm to -a HorizontalAnnotation and add it as an annotation to another graph. - -This might be useful if: - -- You want to show multiple alarms inside a single graph, for example if - you have both a "small margin/long period" alarm as well as a - "large margin/short period" alarm. - -- You want to show an Alarm line in a graph with multiple metrics in it. +Check whether the given construct is a Resource. -#### Static Functions +###### `construct`Required -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +- *Type:* constructs.IConstruct --- -##### ~~`isConstruct`~~ +##### `fromServiceArnWithCluster` ```typescript -import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { FargateService } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaErrorsAlarm.isConstruct(x: any) +FargateService.fromServiceArnWithCluster(scope: Construct, id: string, serviceArn: string) ``` -Checks if `x` is a construct. - -###### `x`Required - -- *Type:* any - -Any object. - ---- - -##### `isOwnedResource` - -```typescript -import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +Import an existing ECS/Fargate Service using the service cluster format. -LambdaErrorsAlarm.isOwnedResource(construct: IConstruct) -``` +The format is the "new" format "arn:aws:ecs:region:aws_account_id:service/cluster-name/service-name". -Returns true if the construct was created by CDK, and false otherwise. +> [https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-settings.html#ecs-resource-ids](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-settings.html#ecs-resource-ids) -###### `construct`Required +###### `scope`Required -- *Type:* constructs.IConstruct +- *Type:* constructs.Construct --- -##### `isResource` - -```typescript -import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +###### `id`Required -LambdaErrorsAlarm.isResource(construct: IConstruct) -``` +- *Type:* string -Check whether the given construct is a Resource. +--- -###### `construct`Required +###### `serviceArn`Required -- *Type:* constructs.IConstruct +- *Type:* string --- -##### `fromAlarmArn` +##### `fromFargateServiceArn` ```typescript -import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { FargateService } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaErrorsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +FargateService.fromFargateServiceArn(scope: Construct, id: string, fargateServiceArn: string) ``` -Import an existing CloudWatch alarm provided an ARN. +Imports from the specified service ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct -The parent creating construct (usually `this`). - --- -###### `id`Required +###### `id`Required - *Type:* string -The construct's name. - --- -###### `alarmArn`Required +###### `fargateServiceArn`Required - *Type:* string -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). - --- -##### `fromAlarmName` +##### `fromFargateServiceAttributes` ```typescript -import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { FargateService } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaErrorsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +FargateService.fromFargateServiceAttributes(scope: Construct, id: string, attrs: FargateServiceAttributes) ``` -Import an existing CloudWatch alarm provided an Name. +Imports from the specified service attributes. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct -The parent creating construct (usually `this`). - --- -###### `id`Required +###### `id`Required - *Type:* string -The construct's name. - --- -###### `alarmName`Required - -- *Type:* string +###### `attrs`Required -Alarm Name. +- *Type:* aws-cdk-lib.aws_ecs.FargateServiceAttributes --- @@ -5060,16 +5098,19 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| cluster | aws-cdk-lib.aws_ecs.ICluster | The cluster that hosts the service. | +| connections | aws-cdk-lib.aws_ec2.Connections | The security groups which manage the allowed network traffic for the service. | +| serviceArn | string | The Amazon Resource Name (ARN) of the service. | +| serviceName | string | The name of the service. | +| taskDefinition | aws-cdk-lib.aws_ecs.TaskDefinition | The task definition to use for tasks in the service. | +| cloudMapService | aws-cdk-lib.aws_servicediscovery.IService | The CloudMap service created for this service, if any. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -5081,7 +5122,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -5100,7 +5141,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -5112,122 +5153,4508 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `cluster`Required ```typescript -public readonly alarmArn: string; +public readonly cluster: ICluster; ``` -- *Type:* string +- *Type:* aws-cdk-lib.aws_ecs.ICluster -ARN of this alarm. +The cluster that hosts the service. --- -##### `alarmName`Required +##### `connections`Required ```typescript -public readonly alarmName: string; +public readonly connections: Connections; ``` -- *Type:* string +- *Type:* aws-cdk-lib.aws_ec2.Connections -Name of this alarm. +The security groups which manage the allowed network traffic for the service. --- -##### `metric`Required +##### `serviceArn`Required ```typescript -public readonly metric: IMetric; +public readonly serviceArn: string; ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +- *Type:* string -The metric object this alarm was based on. +The Amazon Resource Name (ARN) of the service. --- +##### `serviceName`Required -### LambdaRecommendedAlarms +```typescript +public readonly serviceName: string; +``` -A construct that creates recommended alarms for a Lambda function. +- *Type:* string -> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda) +The name of the service. -#### Initializers +--- -```typescript -import { LambdaRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' +##### `taskDefinition`Required -new LambdaRecommendedAlarms(scope: Construct, id: string, props: LambdaRecommendedAlarmsProps) +```typescript +public readonly taskDefinition: TaskDefinition; ``` -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | LambdaRecommendedAlarmsProps | *No description.* | - ---- - -##### `scope`Required +- *Type:* aws-cdk-lib.aws_ecs.TaskDefinition -- *Type:* constructs.Construct +The task definition to use for tasks in the service. --- -##### `id`Required - -- *Type:* string +##### `cloudMapService`Optional ---- +```typescript +public readonly cloudMapService: IService; +``` -##### `props`Required +- *Type:* aws-cdk-lib.aws_servicediscovery.IService -- *Type:* LambdaRecommendedAlarmsProps +The CloudMap service created for this service, if any. --- -#### Methods -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | +### Function ---- +An extension of the Lambda function construct that provides methods to create recommended alarms. -##### `toString` +#### Initializers ```typescript -public toString(): string +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new Function(scope: Construct, id: string, props: FunctionProps) ``` -Returns a string representation of this construct. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | aws-cdk-lib.aws_lambda.FunctionProps | *No description.* | -#### Static Functions +--- -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | +##### `scope`Required + +- *Type:* constructs.Construct --- -##### ~~`isConstruct`~~ +##### `id`Required -```typescript -import { LambdaRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' +- *Type:* string -LambdaRecommendedAlarms.isConstruct(x: any) -``` +--- -Checks if `x` is a construct. +##### `props`Required -###### `x`Required +- *Type:* aws-cdk-lib.aws_lambda.FunctionProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addEventSource | Adds an event source to this function. | +| addEventSourceMapping | Adds an event source that maps to this AWS Lambda function. | +| addFunctionUrl | Adds a url to this lambda function. | +| addPermission | Adds a permission to the Lambda resource policy. | +| addToRolePolicy | Adds a statement to the IAM role assumed by the instance. | +| configureAsyncInvoke | Configures options for asynchronous invocation. | +| considerWarningOnInvokeFunctionPermissions | A warning will be added to functions under the following conditions: - permissions that include `lambda:InvokeFunction` are added to the unqualified function. | +| grantInvoke | Grant the given identity permissions to invoke this Lambda. | +| grantInvokeCompositePrincipal | Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. | +| grantInvokeLatestVersion | Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda. | +| grantInvokeUrl | Grant the given identity permissions to invoke this Lambda Function URL. | +| grantInvokeVersion | Grant the given identity permissions to invoke the given version of this Lambda. | +| metric | Return the given named metric for this Function. | +| metricDuration | How long execution of this Lambda takes. | +| metricErrors | How many invocations of this Lambda fail. | +| metricInvocations | How often this Lambda is invoked. | +| metricThrottles | How often this Lambda is throttled. | +| addAlias | Defines an alias for this function. | +| addEnvironment | Adds an environment variable to this Lambda function. | +| addLayers | Adds one or more Lambda Layers to this Lambda function. | +| invalidateVersionBasedOn | Mix additional information into the hash of the Version object. | +| alarmConcurrentExecutions | Creates an alarm that monitors the number of concurrent executions. | +| alarmDuration | Creates an alarm that monitors the duration of the function invocations. | +| alarmErrors | Creates an alarm that monitors the number of errors. | +| alarmThrottles | Creates an alarm that monitors the number of throttles. | +| applyRecommendedAlarms | Creates recommended alarms for the Lambda function. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addEventSource` + +```typescript +public addEventSource(source: IEventSource): void +``` + +Adds an event source to this function. + +Event sources are implemented in the aws-cdk-lib/aws-lambda-event-sources module. + +The following example adds an SQS Queue as an event source: +``` +import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; +myFunction.addEventSource(new SqsEventSource(myQueue)); +``` + +###### `source`Required + +- *Type:* aws-cdk-lib.aws_lambda.IEventSource + +--- + +##### `addEventSourceMapping` + +```typescript +public addEventSourceMapping(id: string, options: EventSourceMappingOptions): EventSourceMapping +``` + +Adds an event source that maps to this AWS Lambda function. + +###### `id`Required + +- *Type:* string + +--- + +###### `options`Required + +- *Type:* aws-cdk-lib.aws_lambda.EventSourceMappingOptions + +--- + +##### `addFunctionUrl` + +```typescript +public addFunctionUrl(options?: FunctionUrlOptions): FunctionUrl +``` + +Adds a url to this lambda function. + +###### `options`Optional + +- *Type:* aws-cdk-lib.aws_lambda.FunctionUrlOptions + +--- + +##### `addPermission` + +```typescript +public addPermission(id: string, permission: Permission): void +``` + +Adds a permission to the Lambda resource policy. + +> [Permission for details.](Permission for details.) + +###### `id`Required + +- *Type:* string + +The id for the permission construct. + +--- + +###### `permission`Required + +- *Type:* aws-cdk-lib.aws_lambda.Permission + +The permission to grant to this Lambda function. + +--- + +##### `addToRolePolicy` + +```typescript +public addToRolePolicy(statement: PolicyStatement): void +``` + +Adds a statement to the IAM role assumed by the instance. + +###### `statement`Required + +- *Type:* aws-cdk-lib.aws_iam.PolicyStatement + +--- + +##### `configureAsyncInvoke` + +```typescript +public configureAsyncInvoke(options: EventInvokeConfigOptions): void +``` + +Configures options for asynchronous invocation. + +###### `options`Required + +- *Type:* aws-cdk-lib.aws_lambda.EventInvokeConfigOptions + +--- + +##### `considerWarningOnInvokeFunctionPermissions` + +```typescript +public considerWarningOnInvokeFunctionPermissions(scope: Construct, action: string): void +``` + +A warning will be added to functions under the following conditions: - permissions that include `lambda:InvokeFunction` are added to the unqualified function. + +function.currentVersion is invoked before or after the permission is created. + +This applies only to permissions on Lambda functions, not versions or aliases. +This function is overridden as a noOp for QualifiedFunctionBase. + +###### `scope`Required + +- *Type:* constructs.Construct + +--- + +###### `action`Required + +- *Type:* string + +--- + +##### `grantInvoke` + +```typescript +public grantInvoke(grantee: IGrantable): Grant +``` + +Grant the given identity permissions to invoke this Lambda. + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +--- + +##### `grantInvokeCompositePrincipal` + +```typescript +public grantInvokeCompositePrincipal(compositePrincipal: CompositePrincipal): Grant[] +``` + +Grant multiple principals the ability to invoke this Lambda via CompositePrincipal. + +###### `compositePrincipal`Required + +- *Type:* aws-cdk-lib.aws_iam.CompositePrincipal + +--- + +##### `grantInvokeLatestVersion` + +```typescript +public grantInvokeLatestVersion(grantee: IGrantable): Grant +``` + +Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda. + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +--- + +##### `grantInvokeUrl` + +```typescript +public grantInvokeUrl(grantee: IGrantable): Grant +``` + +Grant the given identity permissions to invoke this Lambda Function URL. + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +--- + +##### `grantInvokeVersion` + +```typescript +public grantInvokeVersion(grantee: IGrantable, version: IVersion): Grant +``` + +Grant the given identity permissions to invoke the given version of this Lambda. + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +--- + +###### `version`Required + +- *Type:* aws-cdk-lib.aws_lambda.IVersion + +--- + +##### `metric` + +```typescript +public metric(metricName: string, props?: MetricOptions): Metric +``` + +Return the given named metric for this Function. + +###### `metricName`Required + +- *Type:* string + +--- + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricDuration` + +```typescript +public metricDuration(props?: MetricOptions): Metric +``` + +How long execution of this Lambda takes. + +Average over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricErrors` + +```typescript +public metricErrors(props?: MetricOptions): Metric +``` + +How many invocations of this Lambda fail. + +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricInvocations` + +```typescript +public metricInvocations(props?: MetricOptions): Metric +``` + +How often this Lambda is invoked. + +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricThrottles` + +```typescript +public metricThrottles(props?: MetricOptions): Metric +``` + +How often this Lambda is throttled. + +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `addAlias` + +```typescript +public addAlias(aliasName: string, options?: AliasOptions): Alias +``` + +Defines an alias for this function. + +The alias will automatically be updated to point to the latest version of +the function as it is being updated during a deployment. + +```ts +declare const fn: lambda.Function; + +fn.addAlias('Live'); + +// Is equivalent to + +new lambda.Alias(this, 'AliasLive', { + aliasName: 'Live', + version: fn.currentVersion, +}); +``` + +###### `aliasName`Required + +- *Type:* string + +The name of the alias. + +--- + +###### `options`Optional + +- *Type:* aws-cdk-lib.aws_lambda.AliasOptions + +Alias options. + +--- + +##### `addEnvironment` + +```typescript +public addEnvironment(key: string, value: string, options?: EnvironmentOptions): Function +``` + +Adds an environment variable to this Lambda function. + +If this is a ref to a Lambda function, this operation results in a no-op. + +###### `key`Required + +- *Type:* string + +The environment variable key. + +--- + +###### `value`Required + +- *Type:* string + +The environment variable's value. + +--- + +###### `options`Optional + +- *Type:* aws-cdk-lib.aws_lambda.EnvironmentOptions + +Environment variable options. + +--- + +##### `addLayers` + +```typescript +public addLayers(layers: ILayerVersion): void +``` + +Adds one or more Lambda Layers to this Lambda function. + +###### `layers`Required + +- *Type:* aws-cdk-lib.aws_lambda.ILayerVersion + +the layers to be added. + +--- + +##### `invalidateVersionBasedOn` + +```typescript +public invalidateVersionBasedOn(x: string): void +``` + +Mix additional information into the hash of the Version object. + +The Lambda Function construct does its best to automatically create a new +Version when anything about the Function changes (its code, its layers, +any of the other properties). + +However, you can sometimes source information from places that the CDK cannot +look into, like the deploy-time values of SSM parameters. In those cases, +the CDK would not force the creation of a new Version object when it actually +should. + +This method can be used to invalidate the current Version object. Pass in +any string into this method, and make sure the string changes when you know +a new Version needs to be created. + +This method may be called more than once. + +###### `x`Required + +- *Type:* string + +--- + +##### `alarmConcurrentExecutions` + +```typescript +public alarmConcurrentExecutions(props?: LambdaConcurrentExecutionsAlarmConfig): LambdaConcurrentExecutionsAlarm +``` + +Creates an alarm that monitors the number of concurrent executions. + +###### `props`Optional + +- *Type:* LambdaConcurrentExecutionsAlarmConfig + +--- + +##### `alarmDuration` + +```typescript +public alarmDuration(props: LambdaDurationAlarmConfig): LambdaDurationAlarm +``` + +Creates an alarm that monitors the duration of the function invocations. + +###### `props`Required + +- *Type:* LambdaDurationAlarmConfig + +--- + +##### `alarmErrors` + +```typescript +public alarmErrors(props: LambdaErrorsAlarmConfig): LambdaErrorsAlarm +``` + +Creates an alarm that monitors the number of errors. + +###### `props`Required + +- *Type:* LambdaErrorsAlarmConfig + +--- + +##### `alarmThrottles` + +```typescript +public alarmThrottles(props: LambdaThrottlesAlarmConfig): LambdaThrottlesAlarm +``` + +Creates an alarm that monitors the number of throttles. + +###### `props`Required + +- *Type:* LambdaThrottlesAlarmConfig + +--- + +##### `applyRecommendedAlarms` + +```typescript +public applyRecommendedAlarms(props: LambdaRecommendedAlarmsConfig): LambdaRecommendedAlarms +``` + +Creates recommended alarms for the Lambda function. + +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda) + +###### `props`Required + +- *Type:* LambdaRecommendedAlarmsConfig + +--- + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| classifyVersionProperty | Record whether specific properties in the `AWS::Lambda::Function` resource should also be associated to the Version resource. | +| fromFunctionArn | Import a lambda function into the CDK using its ARN. | +| fromFunctionAttributes | Creates a Lambda function object which represents a function not defined within this stack. | +| fromFunctionName | Import a lambda function into the CDK using its name. | +| metricAll | Return the given named metric for this Lambda. | +| metricAllConcurrentExecutions | Metric for the number of concurrent executions across all Lambdas. | +| metricAllDuration | Metric for the Duration executing all Lambdas. | +| metricAllErrors | Metric for the number of Errors executing all Lambdas. | +| metricAllInvocations | Metric for the number of invocations of all Lambdas. | +| metricAllThrottles | Metric for the number of throttled invocations of all Lambdas. | +| metricAllUnreservedConcurrentExecutions | Metric for the number of unreserved concurrent executions across all Lambdas. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `classifyVersionProperty` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.classifyVersionProperty(propertyName: string, locked: boolean) +``` + +Record whether specific properties in the `AWS::Lambda::Function` resource should also be associated to the Version resource. + +See 'currentVersion' section in the module README for more details. + +###### `propertyName`Required + +- *Type:* string + +The property to classify. + +--- + +###### `locked`Required + +- *Type:* boolean + +whether the property should be associated to the version or not. + +--- + +##### `fromFunctionArn` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.fromFunctionArn(scope: Construct, id: string, functionArn: string) +``` + +Import a lambda function into the CDK using its ARN. + +For `Function.addPermissions()` to work on this imported lambda, make sure that is +in the same account and region as the stack you are importing it into. + +###### `scope`Required + +- *Type:* constructs.Construct + +--- + +###### `id`Required + +- *Type:* string + +--- + +###### `functionArn`Required + +- *Type:* string + +--- + +##### `fromFunctionAttributes` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.fromFunctionAttributes(scope: Construct, id: string, attrs: FunctionAttributes) +``` + +Creates a Lambda function object which represents a function not defined within this stack. + +For `Function.addPermissions()` to work on this imported lambda, set the sameEnvironment property to true +if this imported lambda is in the same account and region as the stack you are importing it into. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent construct. + +--- + +###### `id`Required + +- *Type:* string + +The name of the lambda construct. + +--- + +###### `attrs`Required + +- *Type:* aws-cdk-lib.aws_lambda.FunctionAttributes + +the attributes of the function to import. + +--- + +##### `fromFunctionName` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.fromFunctionName(scope: Construct, id: string, functionName: string) +``` + +Import a lambda function into the CDK using its name. + +###### `scope`Required + +- *Type:* constructs.Construct + +--- + +###### `id`Required + +- *Type:* string + +--- + +###### `functionName`Required + +- *Type:* string + +--- + +##### `metricAll` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.metricAll(metricName: string, props?: MetricOptions) +``` + +Return the given named metric for this Lambda. + +###### `metricName`Required + +- *Type:* string + +--- + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricAllConcurrentExecutions` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.metricAllConcurrentExecutions(props?: MetricOptions) +``` + +Metric for the number of concurrent executions across all Lambdas. + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricAllDuration` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.metricAllDuration(props?: MetricOptions) +``` + +Metric for the Duration executing all Lambdas. + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricAllErrors` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.metricAllErrors(props?: MetricOptions) +``` + +Metric for the number of Errors executing all Lambdas. + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricAllInvocations` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.metricAllInvocations(props?: MetricOptions) +``` + +Metric for the number of invocations of all Lambdas. + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricAllThrottles` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.metricAllThrottles(props?: MetricOptions) +``` + +Metric for the number of throttled invocations of all Lambdas. + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricAllUnreservedConcurrentExecutions` + +```typescript +import { Function } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Function.metricAllUnreservedConcurrentExecutions(props?: MetricOptions) +``` + +Metric for the number of unreserved concurrent executions across all Lambdas. + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| architecture | aws-cdk-lib.aws_lambda.Architecture | The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64). | +| connections | aws-cdk-lib.aws_ec2.Connections | Access the Connections object. | +| functionArn | string | ARN of this function. | +| functionName | string | Name of this function. | +| grantPrincipal | aws-cdk-lib.aws_iam.IPrincipal | The principal this Lambda Function is running as. | +| isBoundToVpc | boolean | Whether or not this Lambda function was bound to a VPC. | +| latestVersion | aws-cdk-lib.aws_lambda.IVersion | The `$LATEST` version of this function. | +| permissionsNode | constructs.Node | The construct node where permissions are attached. | +| resourceArnsForGrantInvoke | string[] | The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). | +| role | aws-cdk-lib.aws_iam.IRole | Execution role associated with this function. | +| currentVersion | aws-cdk-lib.aws_lambda.Version | Returns a `lambda.Version` which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes. | +| logGroup | aws-cdk-lib.aws_logs.ILogGroup | The LogGroup where the Lambda function's logs are made available. | +| runtime | aws-cdk-lib.aws_lambda.Runtime | The runtime configured for this lambda. | +| deadLetterQueue | aws-cdk-lib.aws_sqs.IQueue | The DLQ (as queue) associated with this Lambda Function (this is an optional attribute). | +| deadLetterTopic | aws-cdk-lib.aws_sns.ITopic | The DLQ (as topic) associated with this Lambda Function (this is an optional attribute). | +| timeout | aws-cdk-lib.Duration | The timeout configured for this lambda. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `architecture`Required + +```typescript +public readonly architecture: Architecture; +``` + +- *Type:* aws-cdk-lib.aws_lambda.Architecture + +The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64). + +--- + +##### `connections`Required + +```typescript +public readonly connections: Connections; +``` + +- *Type:* aws-cdk-lib.aws_ec2.Connections + +Access the Connections object. + +Will fail if not a VPC-enabled Lambda Function + +--- + +##### `functionArn`Required + +```typescript +public readonly functionArn: string; +``` + +- *Type:* string + +ARN of this function. + +--- + +##### `functionName`Required + +```typescript +public readonly functionName: string; +``` + +- *Type:* string + +Name of this function. + +--- + +##### `grantPrincipal`Required + +```typescript +public readonly grantPrincipal: IPrincipal; +``` + +- *Type:* aws-cdk-lib.aws_iam.IPrincipal + +The principal this Lambda Function is running as. + +--- + +##### `isBoundToVpc`Required + +```typescript +public readonly isBoundToVpc: boolean; +``` + +- *Type:* boolean + +Whether or not this Lambda function was bound to a VPC. + +If this is is `false`, trying to access the `connections` object will fail. + +--- + +##### `latestVersion`Required + +```typescript +public readonly latestVersion: IVersion; +``` + +- *Type:* aws-cdk-lib.aws_lambda.IVersion + +The `$LATEST` version of this function. + +Note that this is reference to a non-specific AWS Lambda version, which +means the function this version refers to can return different results in +different invocations. + +To obtain a reference to an explicit version which references the current +function configuration, use `lambdaFunction.currentVersion` instead. + +--- + +##### `permissionsNode`Required + +```typescript +public readonly permissionsNode: Node; +``` + +- *Type:* constructs.Node + +The construct node where permissions are attached. + +--- + +##### `resourceArnsForGrantInvoke`Required + +```typescript +public readonly resourceArnsForGrantInvoke: string[]; +``` + +- *Type:* string[] + +The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). + +--- + +##### `role`Optional + +```typescript +public readonly role: IRole; +``` + +- *Type:* aws-cdk-lib.aws_iam.IRole + +Execution role associated with this function. + +--- + +##### `currentVersion`Required + +```typescript +public readonly currentVersion: Version; +``` + +- *Type:* aws-cdk-lib.aws_lambda.Version + +Returns a `lambda.Version` which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes. + +You can specify options for this version using the `currentVersionOptions` +prop when initializing the `lambda.Function`. + +--- + +##### `logGroup`Required + +```typescript +public readonly logGroup: ILogGroup; +``` + +- *Type:* aws-cdk-lib.aws_logs.ILogGroup + +The LogGroup where the Lambda function's logs are made available. + +If either `logRetention` is set or this property is called, a CloudFormation custom resource is added to the stack that +pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the correct log retention +period (never expire, by default). + +Further, if the log group already exists and the `logRetention` is not set, the custom resource will reset the log retention +to never expire even if it was configured with a different value. + +--- + +##### `runtime`Required + +```typescript +public readonly runtime: Runtime; +``` + +- *Type:* aws-cdk-lib.aws_lambda.Runtime + +The runtime configured for this lambda. + +--- + +##### `deadLetterQueue`Optional + +```typescript +public readonly deadLetterQueue: IQueue; +``` + +- *Type:* aws-cdk-lib.aws_sqs.IQueue + +The DLQ (as queue) associated with this Lambda Function (this is an optional attribute). + +--- + +##### `deadLetterTopic`Optional + +```typescript +public readonly deadLetterTopic: ITopic; +``` + +- *Type:* aws-cdk-lib.aws_sns.ITopic + +The DLQ (as topic) associated with this Lambda Function (this is an optional attribute). + +--- + +##### `timeout`Optional + +```typescript +public readonly timeout: Duration; +``` + +- *Type:* aws-cdk-lib.Duration + +The timeout configured for this lambda. + +--- + + +### LambdaConcurrentExecutionsAlarm + +This alarm can proactively detect if the concurrency of the function is approaching the Region-level concurrency quota of your account, so that you can act on it. + +A function is +throttled if it reaches the Region-level concurrency quota +of the account. + +The alarm is triggered when the number of concurrent executions +exceeds the specified threshold. + +#### Initializers + +```typescript +import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new LambdaConcurrentExecutionsAlarm(scope: Construct, id: string, props: LambdaConcurrentExecutionsAlarmProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | LambdaConcurrentExecutionsAlarmProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* LambdaConcurrentExecutionsAlarmProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addAlarmAction` + +```typescript +public addAlarmAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm fires. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addInsufficientDataAction` + +```typescript +public addInsufficientDataAction(actions: IAlarmAction): void +``` + +Trigger this action if there is insufficient data to evaluate the alarm. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addOkAction` + +```typescript +public addOkAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `renderAlarmRule` + +```typescript +public renderAlarmRule(): string +``` + +AlarmRule indicating ALARM state for Alarm. + +##### `toAnnotation` + +```typescript +public toAnnotation(): HorizontalAnnotation +``` + +Turn this alarm into a horizontal annotation. + +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. + +This might be useful if: + +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. + +- You want to show an Alarm line in a graph with multiple metrics in it. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaConcurrentExecutionsAlarm.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaConcurrentExecutionsAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaConcurrentExecutionsAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaConcurrentExecutionsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` + +```typescript +import { LambdaConcurrentExecutionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaConcurrentExecutionsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` + +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` + +- *Type:* string + +ARN of this alarm. + +--- + +##### `alarmName`Required + +```typescript +public readonly alarmName: string; +``` + +- *Type:* string + +Name of this alarm. + +--- + +##### `metric`Required + +```typescript +public readonly metric: IMetric; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric + +The metric object this alarm was based on. + +--- + + +### LambdaDurationAlarm + +This alarm can detect a long running duration of a Lambda function. + +High runtime duration indicates that +a function is taking a longer time for invocation, and +can also impact the concurrency capacity of invocation +if Lambda is handling a higher number of events. It is +critical to know if the Lambda function is constantly +taking longer execution time than expected. + +The alarm is triggered when the duration of the function +invocations exceeds the specified threshold. + +#### Initializers + +```typescript +import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new LambdaDurationAlarm(scope: Construct, id: string, props: LambdaDurationAlarmProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | LambdaDurationAlarmProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* LambdaDurationAlarmProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addAlarmAction` + +```typescript +public addAlarmAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm fires. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addInsufficientDataAction` + +```typescript +public addInsufficientDataAction(actions: IAlarmAction): void +``` + +Trigger this action if there is insufficient data to evaluate the alarm. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addOkAction` + +```typescript +public addOkAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `renderAlarmRule` + +```typescript +public renderAlarmRule(): string +``` + +AlarmRule indicating ALARM state for Alarm. + +##### `toAnnotation` + +```typescript +public toAnnotation(): HorizontalAnnotation +``` + +Turn this alarm into a horizontal annotation. + +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. + +This might be useful if: + +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. + +- You want to show an Alarm line in a graph with multiple metrics in it. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaDurationAlarm.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaDurationAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaDurationAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaDurationAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` + +```typescript +import { LambdaDurationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaDurationAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` + +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` + +- *Type:* string + +ARN of this alarm. + +--- + +##### `alarmName`Required + +```typescript +public readonly alarmName: string; +``` + +- *Type:* string + +Name of this alarm. + +--- + +##### `metric`Required + +```typescript +public readonly metric: IMetric; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric + +The metric object this alarm was based on. + +--- + + +### LambdaErrorsAlarm + +The alarm helps detect high error counts in function invocations. + +The alarm is triggered when the number of errors exceeds the specified +threshold. + +#### Initializers + +```typescript +import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new LambdaErrorsAlarm(scope: Construct, id: string, props: LambdaErrorsAlarmProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | LambdaErrorsAlarmProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* LambdaErrorsAlarmProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addAlarmAction` + +```typescript +public addAlarmAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm fires. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addInsufficientDataAction` + +```typescript +public addInsufficientDataAction(actions: IAlarmAction): void +``` + +Trigger this action if there is insufficient data to evaluate the alarm. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addOkAction` + +```typescript +public addOkAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `renderAlarmRule` + +```typescript +public renderAlarmRule(): string +``` + +AlarmRule indicating ALARM state for Alarm. + +##### `toAnnotation` + +```typescript +public toAnnotation(): HorizontalAnnotation +``` + +Turn this alarm into a horizontal annotation. + +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. + +This might be useful if: + +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. + +- You want to show an Alarm line in a graph with multiple metrics in it. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaErrorsAlarm.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaErrorsAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaErrorsAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaErrorsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` + +```typescript +import { LambdaErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaErrorsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` + +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` + +- *Type:* string + +ARN of this alarm. + +--- + +##### `alarmName`Required + +```typescript +public readonly alarmName: string; +``` + +- *Type:* string + +Name of this alarm. + +--- + +##### `metric`Required + +```typescript +public readonly metric: IMetric; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric + +The metric object this alarm was based on. + +--- + + +### LambdaRecommendedAlarms + +A construct that creates recommended alarms for a Lambda function. + +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#Lambda) + +#### Initializers + +```typescript +import { LambdaRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new LambdaRecommendedAlarms(scope: Construct, id: string, props: LambdaRecommendedAlarmsProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | LambdaRecommendedAlarmsProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* LambdaRecommendedAlarmsProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { LambdaRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaRecommendedAlarms.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| alarmConcurrentExecutions | LambdaConcurrentExecutionsAlarm | The concurrent executions alarm for the Lambda function. | +| alarmDuration | LambdaDurationAlarm | The duration alarm for the Lambda function. | +| alarmErrors | LambdaErrorsAlarm | The error alarm for the Lambda function. | +| alarmThrottles | LambdaThrottlesAlarm | The throttles alarm for the Lambda function. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `alarmConcurrentExecutions`Optional + +```typescript +public readonly alarmConcurrentExecutions: LambdaConcurrentExecutionsAlarm; +``` + +- *Type:* LambdaConcurrentExecutionsAlarm + +The concurrent executions alarm for the Lambda function. + +--- + +##### `alarmDuration`Optional + +```typescript +public readonly alarmDuration: LambdaDurationAlarm; +``` + +- *Type:* LambdaDurationAlarm + +The duration alarm for the Lambda function. + +--- + +##### `alarmErrors`Optional + +```typescript +public readonly alarmErrors: LambdaErrorsAlarm; +``` + +- *Type:* LambdaErrorsAlarm + +The error alarm for the Lambda function. + +--- + +##### `alarmThrottles`Optional + +```typescript +public readonly alarmThrottles: LambdaThrottlesAlarm; +``` + +- *Type:* LambdaThrottlesAlarm + +The throttles alarm for the Lambda function. + +--- + + +### LambdaThrottlesAlarm + +The alarm helps detect a high number of throttled invocation requests for a Lambda function. + +It is important to know if requests are constantly +getting rejected due to throttling and if you need to improve Lambda +function performance or increase concurrency capacity to avoid constant +throttling. + +The alarm is triggered when the number of throttles exceeds or equals +the specified threshold. + +#### Initializers + +```typescript +import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new LambdaThrottlesAlarm(scope: Construct, id: string, props: LambdaThrottlesAlarmProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | LambdaThrottlesAlarmProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* LambdaThrottlesAlarmProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addAlarmAction` + +```typescript +public addAlarmAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm fires. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addInsufficientDataAction` + +```typescript +public addInsufficientDataAction(actions: IAlarmAction): void +``` + +Trigger this action if there is insufficient data to evaluate the alarm. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addOkAction` + +```typescript +public addOkAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `renderAlarmRule` + +```typescript +public renderAlarmRule(): string +``` + +AlarmRule indicating ALARM state for Alarm. + +##### `toAnnotation` + +```typescript +public toAnnotation(): HorizontalAnnotation +``` + +Turn this alarm into a horizontal annotation. + +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. + +This might be useful if: + +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. + +- You want to show an Alarm line in a graph with multiple metrics in it. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaThrottlesAlarm.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaThrottlesAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaThrottlesAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaThrottlesAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` + +```typescript +import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +LambdaThrottlesAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` + +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` + +- *Type:* string + +ARN of this alarm. + +--- + +##### `alarmName`Required + +```typescript +public readonly alarmName: string; +``` + +- *Type:* string + +Name of this alarm. + +--- + +##### `metric`Required + +```typescript +public readonly metric: IMetric; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric + +The metric object this alarm was based on. + +--- + + +### Queue + +An extension of the SQS Queue construct that adds methods to create recommended alarms. + +#### Initializers + +```typescript +import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new Queue(scope: Construct, id: string, props?: QueueProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | aws-cdk-lib.aws_sqs.QueueProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Optional + +- *Type:* aws-cdk-lib.aws_sqs.QueueProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addToResourcePolicy | Adds a statement to the IAM resource policy associated with this queue. | +| grant | Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource. | +| grantConsumeMessages | Grant permissions to consume messages from a queue. | +| grantPurge | Grant an IAM principal permissions to purge all messages from the queue. | +| grantSendMessages | Grant access to send messages to a queue to the given identity. | +| metric | Return the given named metric for this Queue. | +| metricApproximateAgeOfOldestMessage | The approximate age of the oldest non-deleted message in the queue. | +| metricApproximateNumberOfMessagesDelayed | The number of messages in the queue that are delayed and not available for reading immediately. | +| metricApproximateNumberOfMessagesNotVisible | The number of messages that are in flight. | +| metricApproximateNumberOfMessagesVisible | The number of messages available for retrieval from the queue. | +| metricNumberOfEmptyReceives | The number of ReceiveMessage API calls that did not return a message. | +| metricNumberOfMessagesDeleted | The number of messages deleted from the queue. | +| metricNumberOfMessagesReceived | The number of messages returned by calls to the ReceiveMessage action. | +| metricNumberOfMessagesSent | The number of messages added to a queue. | +| metricSentMessageSize | The size of messages added to a queue. | +| alarmApproximateAgeOfOldestMessage | Creates an alarm that watches the age of the oldest message in the queue. | +| alarmApproximateNumberOfMessagesNotVisible | Creates an alarm that watches the number of messages that are in flight. | +| alarmApproximateNumberOfMessagesVisible | Creates an alarm that watches the number of messages that are visible in the queue. | +| alarmNumberOfMessagesSent | Creates an alarm that watches the number of messages that are sent. | +| applyRecommendedAlarms | Creates the recommended alarms for an SQS queue. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addToResourcePolicy` + +```typescript +public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult +``` + +Adds a statement to the IAM resource policy associated with this queue. + +If this queue was created in this stack (`new Queue`), a queue policy +will be automatically created upon the first call to `addToPolicy`. If +the queue is imported (`Queue.import`), then this is a no-op. + +###### `statement`Required + +- *Type:* aws-cdk-lib.aws_iam.PolicyStatement + +--- + +##### `grant` + +```typescript +public grant(grantee: IGrantable, actions: string): Grant +``` + +Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource. + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +Principal to grant right to. + +--- + +###### `actions`Required + +- *Type:* string + +The actions to grant. + +--- + +##### `grantConsumeMessages` + +```typescript +public grantConsumeMessages(grantee: IGrantable): Grant +``` + +Grant permissions to consume messages from a queue. + +This will grant the following permissions: + + - sqs:ChangeMessageVisibility + - sqs:DeleteMessage + - sqs:ReceiveMessage + - sqs:GetQueueAttributes + - sqs:GetQueueUrl + +If encryption is used, permission to use the key to decrypt the contents of the queue will also be granted to the same principal. + +This will grant the following KMS permissions: + + - kms:Decrypt + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +Principal to grant consume rights to. + +--- + +##### `grantPurge` + +```typescript +public grantPurge(grantee: IGrantable): Grant +``` + +Grant an IAM principal permissions to purge all messages from the queue. + +This will grant the following permissions: + + - sqs:PurgeQueue + - sqs:GetQueueAttributes + - sqs:GetQueueUrl + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +Principal to grant send rights to. + +--- + +##### `grantSendMessages` + +```typescript +public grantSendMessages(grantee: IGrantable): Grant +``` + +Grant access to send messages to a queue to the given identity. + +This will grant the following permissions: + + - sqs:SendMessage + - sqs:GetQueueAttributes + - sqs:GetQueueUrl + +If encryption is used, permission to use the key to encrypt/decrypt the contents of the queue will also be granted to the same principal. + +This will grant the following KMS permissions: + + - kms:Decrypt + - kms:Encrypt + - kms:ReEncrypt* + - kms:GenerateDataKey* + +###### `grantee`Required + +- *Type:* aws-cdk-lib.aws_iam.IGrantable + +Principal to grant send rights to. + +--- + +##### `metric` + +```typescript +public metric(metricName: string, props?: MetricOptions): Metric +``` + +Return the given named metric for this Queue. + +###### `metricName`Required + +- *Type:* string + +--- + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricApproximateAgeOfOldestMessage` + +```typescript +public metricApproximateAgeOfOldestMessage(props?: MetricOptions): Metric +``` + +The approximate age of the oldest non-deleted message in the queue. + +Maximum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricApproximateNumberOfMessagesDelayed` + +```typescript +public metricApproximateNumberOfMessagesDelayed(props?: MetricOptions): Metric +``` + +The number of messages in the queue that are delayed and not available for reading immediately. + +Maximum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricApproximateNumberOfMessagesNotVisible` + +```typescript +public metricApproximateNumberOfMessagesNotVisible(props?: MetricOptions): Metric +``` + +The number of messages that are in flight. + +Maximum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricApproximateNumberOfMessagesVisible` + +```typescript +public metricApproximateNumberOfMessagesVisible(props?: MetricOptions): Metric +``` + +The number of messages available for retrieval from the queue. + +Maximum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricNumberOfEmptyReceives` + +```typescript +public metricNumberOfEmptyReceives(props?: MetricOptions): Metric +``` + +The number of ReceiveMessage API calls that did not return a message. + +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricNumberOfMessagesDeleted` + +```typescript +public metricNumberOfMessagesDeleted(props?: MetricOptions): Metric +``` + +The number of messages deleted from the queue. + +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricNumberOfMessagesReceived` + +```typescript +public metricNumberOfMessagesReceived(props?: MetricOptions): Metric +``` + +The number of messages returned by calls to the ReceiveMessage action. + +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricNumberOfMessagesSent` + +```typescript +public metricNumberOfMessagesSent(props?: MetricOptions): Metric +``` + +The number of messages added to a queue. + +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `metricSentMessageSize` + +```typescript +public metricSentMessageSize(props?: MetricOptions): Metric +``` + +The size of messages added to a queue. + +Average over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions + +--- + +##### `alarmApproximateAgeOfOldestMessage` + +```typescript +public alarmApproximateAgeOfOldestMessage(props: SqsApproximateAgeOfOldestMessageAlarmConfig): SqsApproximateAgeOfOldestMessageAlarm +``` + +Creates an alarm that watches the age of the oldest message in the queue. + +###### `props`Required + +- *Type:* SqsApproximateAgeOfOldestMessageAlarmConfig + +--- + +##### `alarmApproximateNumberOfMessagesNotVisible` + +```typescript +public alarmApproximateNumberOfMessagesNotVisible(props: SqsApproximateNumberOfMessagesNotVisibleAlarmConfig): SqsApproximateNumberOfMessagesNotVisibleAlarm +``` + +Creates an alarm that watches the number of messages that are in flight. + +###### `props`Required + +- *Type:* SqsApproximateNumberOfMessagesNotVisibleAlarmConfig + +--- + +##### `alarmApproximateNumberOfMessagesVisible` + +```typescript +public alarmApproximateNumberOfMessagesVisible(props: SqsApproximateNumberOfMessagesVisibleAlarmConfig): SqsApproximateNumberOfMessagesVisibleAlarm +``` + +Creates an alarm that watches the number of messages that are visible in the queue. + +###### `props`Required + +- *Type:* SqsApproximateNumberOfMessagesVisibleAlarmConfig + +--- + +##### `alarmNumberOfMessagesSent` + +```typescript +public alarmNumberOfMessagesSent(props?: SqsNumberOfMessagesSentAlarmConfig): SqsNumberOfMessagesSentAlarm +``` + +Creates an alarm that watches the number of messages that are sent. + +###### `props`Optional + +- *Type:* SqsNumberOfMessagesSentAlarmConfig + +--- + +##### `applyRecommendedAlarms` + +```typescript +public applyRecommendedAlarms(props: SqsRecommendedAlarmsConfig): void +``` + +Creates the recommended alarms for an SQS queue. + +###### `props`Required + +- *Type:* SqsRecommendedAlarmsConfig + +--- + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromQueueArn | Import an existing SQS queue provided an ARN. | +| fromQueueAttributes | Import an existing queue. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Queue.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Queue.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Queue.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromQueueArn` + +```typescript +import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Queue.fromQueueArn(scope: Construct, id: string, queueArn: string) +``` + +Import an existing SQS queue provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct. + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `queueArn`Required + +- *Type:* string + +queue ARN (i.e. arn:aws:sqs:us-east-2:444455556666:queue1). + +--- + +##### `fromQueueAttributes` + +```typescript +import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +Queue.fromQueueAttributes(scope: Construct, id: string, attrs: QueueAttributes) +``` + +Import an existing queue. + +###### `scope`Required + +- *Type:* constructs.Construct + +--- + +###### `id`Required + +- *Type:* string + +--- + +###### `attrs`Required + +- *Type:* aws-cdk-lib.aws_sqs.QueueAttributes + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| fifo | boolean | Whether this queue is an Amazon SQS FIFO queue. | +| queueArn | string | The ARN of this queue. | +| queueName | string | The name of this queue. | +| queueUrl | string | The URL of this queue. | +| encryptionMasterKey | aws-cdk-lib.aws_kms.IKey | If this queue is encrypted, this is the KMS key. | +| encryptionType | aws-cdk-lib.aws_sqs.QueueEncryption | Whether the contents of the queue are encrypted, and by what type of key. | +| deadLetterQueue | aws-cdk-lib.aws_sqs.DeadLetterQueue | If this queue is configured with a dead-letter queue, this is the dead-letter queue settings. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `fifo`Required + +```typescript +public readonly fifo: boolean; +``` + +- *Type:* boolean + +Whether this queue is an Amazon SQS FIFO queue. + +If false, this is a standard queue. + +--- + +##### `queueArn`Required + +```typescript +public readonly queueArn: string; +``` + +- *Type:* string + +The ARN of this queue. + +--- + +##### `queueName`Required + +```typescript +public readonly queueName: string; +``` + +- *Type:* string + +The name of this queue. + +--- + +##### `queueUrl`Required + +```typescript +public readonly queueUrl: string; +``` + +- *Type:* string + +The URL of this queue. + +--- + +##### `encryptionMasterKey`Optional + +```typescript +public readonly encryptionMasterKey: IKey; +``` + +- *Type:* aws-cdk-lib.aws_kms.IKey + +If this queue is encrypted, this is the KMS key. + +--- + +##### `encryptionType`Optional + +```typescript +public readonly encryptionType: QueueEncryption; +``` + +- *Type:* aws-cdk-lib.aws_sqs.QueueEncryption + +Whether the contents of the queue are encrypted, and by what type of key. + +--- + +##### `deadLetterQueue`Optional + +```typescript +public readonly deadLetterQueue: DeadLetterQueue; +``` + +- *Type:* aws-cdk-lib.aws_sqs.DeadLetterQueue + +If this queue is configured with a dead-letter queue, this is the dead-letter queue settings. + +--- + + +### RdsAuroraBinLogReplicationLagAlarm + +An alarm that monitors the error state of Aurora writer instance replication. + +This alarm is used to detect whether the writer instance is in an error state and can’t replicate the source. + +The alarm is triggered when the value is less than or equal to threshold. + +#### Initializers + +```typescript +import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new RdsAuroraBinLogReplicationLagAlarm(scope: Construct, id: string, props: RdsAuroraBinLogReplicationLagAlarmProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsAuroraBinLogReplicationLagAlarmProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* RdsAuroraBinLogReplicationLagAlarmProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addAlarmAction` + +```typescript +public addAlarmAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm fires. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addInsufficientDataAction` + +```typescript +public addInsufficientDataAction(actions: IAlarmAction): void +``` + +Trigger this action if there is insufficient data to evaluate the alarm. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addOkAction` + +```typescript +public addOkAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `renderAlarmRule` + +```typescript +public renderAlarmRule(): string +``` + +AlarmRule indicating ALARM state for Alarm. + +##### `toAnnotation` + +```typescript +public toAnnotation(): HorizontalAnnotation +``` + +Turn this alarm into a horizontal annotation. + +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. + +This might be useful if: + +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. + +- You want to show an Alarm line in a graph with multiple metrics in it. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraBinLogReplicationLagAlarm.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraBinLogReplicationLagAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraBinLogReplicationLagAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraBinLogReplicationLagAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` + +```typescript +import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraBinLogReplicationLagAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` + +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` + +- *Type:* string + +ARN of this alarm. + +--- + +##### `alarmName`Required + +```typescript +public readonly alarmName: string; +``` + +- *Type:* string + +Name of this alarm. + +--- + +##### `metric`Required + +```typescript +public readonly metric: IMetric; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric + +The metric object this alarm was based on. + +--- + + +### RdsAuroraRecommendedAlarms + +A construct that creates recommended alarms for an RDS cluster. + +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS) + +#### Initializers + +```typescript +import { RdsAuroraRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new RdsAuroraRecommendedAlarms(scope: Construct, id: string, props: RdsAuroraRecommendedAlarmsProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsAuroraRecommendedAlarmsProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* RdsAuroraRecommendedAlarmsProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { RdsAuroraRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraRecommendedAlarms.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| alarmAuroraBinLogReplicationLag | RdsAuroraBinLogReplicationLagAlarm | The Bin Log Replication lag alarm for the database cluster. | +| alarmAuroraVolumeBytesLeftTotal | RdsAuroraVolumeBytesLeftTotalAlarm | The AuroraVolumeBytesLeftTotal alarm for the database cluster. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `alarmAuroraBinLogReplicationLag`Optional + +```typescript +public readonly alarmAuroraBinLogReplicationLag: RdsAuroraBinLogReplicationLagAlarm; +``` + +- *Type:* RdsAuroraBinLogReplicationLagAlarm + +The Bin Log Replication lag alarm for the database cluster. + +--- + +##### `alarmAuroraVolumeBytesLeftTotal`Optional + +```typescript +public readonly alarmAuroraVolumeBytesLeftTotal: RdsAuroraVolumeBytesLeftTotalAlarm; +``` + +- *Type:* RdsAuroraVolumeBytesLeftTotalAlarm + +The AuroraVolumeBytesLeftTotal alarm for the database cluster. + +--- + + +### RdsAuroraVolumeBytesLeftTotalAlarm + +An alarm that monitors the remaining available space (in bytes) for the cluster volume. + +This alarm is used to detect how close the Aurora cluster is to the volume size limit. This +alarm can prevent an out-of-space error that occurs when your cluster runs out of space. + +The alarm is triggered when the remaining available space (in bytes) is less than threshold. + +#### Initializers + +```typescript +import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new RdsAuroraVolumeBytesLeftTotalAlarm(scope: Construct, id: string, props: RdsAuroraVolumeBytesLeftTotalAlarmProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsAuroraVolumeBytesLeftTotalAlarmProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* RdsAuroraVolumeBytesLeftTotalAlarmProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +##### `addAlarmAction` + +```typescript +public addAlarmAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm fires. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addInsufficientDataAction` + +```typescript +public addInsufficientDataAction(actions: IAlarmAction): void +``` + +Trigger this action if there is insufficient data to evaluate the alarm. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `addOkAction` + +```typescript +public addOkAction(actions: IAlarmAction): void +``` + +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- + +##### `renderAlarmRule` + +```typescript +public renderAlarmRule(): string +``` + +AlarmRule indicating ALARM state for Alarm. + +##### `toAnnotation` + +```typescript +public toAnnotation(): HorizontalAnnotation +``` + +Turn this alarm into a horizontal annotation. + +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. + +This might be useful if: + +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. + +- You want to show an Alarm line in a graph with multiple metrics in it. + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraVolumeBytesLeftTotalAlarm.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required - *Type:* any -Any object. +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraVolumeBytesLeftTotalAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraVolumeBytesLeftTotalAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraVolumeBytesLeftTotalAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` + +```typescript +import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsAuroraVolumeBytesLeftTotalAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` + +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. --- @@ -5235,15 +9662,16 @@ Any object. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| alarmConcurrentExecutions | LambdaConcurrentExecutionsAlarm | The concurrent executions alarm for the Lambda function. | -| alarmDuration | LambdaDurationAlarm | The duration alarm for the Lambda function. | -| alarmErrors | LambdaErrorsAlarm | The error alarm for the Lambda function. | -| alarmThrottles | LambdaThrottlesAlarm | The throttles alarm for the Lambda function. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -5255,98 +9683,114 @@ The tree node. --- -##### `alarmConcurrentExecutions`Optional +##### `env`Required ```typescript -public readonly alarmConcurrentExecutions: LambdaConcurrentExecutionsAlarm; +public readonly env: ResourceEnvironment; ``` -- *Type:* LambdaConcurrentExecutionsAlarm +- *Type:* aws-cdk-lib.ResourceEnvironment -The concurrent executions alarm for the Lambda function. +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. --- -##### `alarmDuration`Optional +##### `stack`Required ```typescript -public readonly alarmDuration: LambdaDurationAlarm; +public readonly stack: Stack; ``` -- *Type:* LambdaDurationAlarm +- *Type:* aws-cdk-lib.Stack -The duration alarm for the Lambda function. +The stack in which this resource is defined. --- -##### `alarmErrors`Optional +##### `alarmArn`Required ```typescript -public readonly alarmErrors: LambdaErrorsAlarm; +public readonly alarmArn: string; ``` -- *Type:* LambdaErrorsAlarm +- *Type:* string -The error alarm for the Lambda function. +ARN of this alarm. --- -##### `alarmThrottles`Optional +##### `alarmName`Required ```typescript -public readonly alarmThrottles: LambdaThrottlesAlarm; +public readonly alarmName: string; ``` -- *Type:* LambdaThrottlesAlarm +- *Type:* string -The throttles alarm for the Lambda function. +Name of this alarm. --- +##### `metric`Required -### LambdaThrottlesAlarm +```typescript +public readonly metric: IMetric; +``` -The alarm helps detect a high number of throttled invocation requests for a Lambda function. +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -It is important to know if requests are constantly -getting rejected due to throttling and if you need to improve Lambda -function performance or increase concurrency capacity to avoid constant -throttling. +The metric object this alarm was based on. -The alarm is triggered when the number of throttles exceeds or equals -the specified threshold. +--- -#### Initializers + +### RdsInstanceCpuUtilizationAlarm + +An alarm that monitors CPU utilization for an RDS instance. + +This alarm is used to detect consistent high CPU utilization in order to prevent very +high response time and time-outs. + +The alarm is triggered when the CPU utilization exceeds the % threshold. + +#### Initializers ```typescript -import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new LambdaThrottlesAlarm(scope: Construct, id: string, props: LambdaThrottlesAlarmProps) +new RdsInstanceCpuUtilizationAlarm(scope: Construct, id: string, props: RdsInstanceCpuUtilizationAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | LambdaThrottlesAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceCpuUtilizationAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* LambdaThrottlesAlarmProps +- *Type:* RdsInstanceCpuUtilizationAlarmProps --- @@ -5354,17 +9798,17 @@ new LambdaThrottlesAlarm(scope: Construct, id: string, props: LambdaThrottlesAla | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -5372,7 +9816,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -5388,13 +9832,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -5404,13 +9848,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -5420,13 +9864,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -5436,13 +9880,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -5450,7 +9894,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -5475,25 +9919,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaThrottlesAlarm.isConstruct(x: any) +RdsInstanceCpuUtilizationAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -5501,49 +9945,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaThrottlesAlarm.isOwnedResource(construct: IConstruct) +RdsInstanceCpuUtilizationAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaThrottlesAlarm.isResource(construct: IConstruct) +RdsInstanceCpuUtilizationAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaThrottlesAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +RdsInstanceCpuUtilizationAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -5551,7 +9995,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -5559,7 +10003,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -5567,17 +10011,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { LambdaThrottlesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -LambdaThrottlesAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +RdsInstanceCpuUtilizationAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -5585,7 +10029,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -5593,7 +10037,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -5605,16 +10049,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -5626,7 +10070,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -5645,7 +10089,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -5657,7 +10101,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -5669,7 +10113,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -5681,7 +10125,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -5694,41 +10138,46 @@ The metric object this alarm was based on. --- -### Queue +### RdsInstanceDatabaseConnectionsAlarm -An extension of the SQS Queue construct that adds methods to create recommended alarms. +An alarm that monitors the number of client network connections to the database instance. -#### Initializers +This alarm is used to help prevent rejected connections when the maximum number of DB +connections is reached. + +The alarm is triggered when number of connections is greater than threshold. + +#### Initializers ```typescript -import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new Queue(scope: Construct, id: string, props?: QueueProps) +new RdsInstanceDatabaseConnectionsAlarm(scope: Construct, id: string, props: RdsInstanceDatabaseConnectionsAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | aws-cdk-lib.aws_sqs.QueueProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceDatabaseConnectionsAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Optional +##### `props`Required -- *Type:* aws-cdk-lib.aws_sqs.QueueProps +- *Type:* RdsInstanceDatabaseConnectionsAlarmProps --- @@ -5736,32 +10185,17 @@ new Queue(scope: Construct, id: string, props?: QueueProps) | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addToResourcePolicy | Adds a statement to the IAM resource policy associated with this queue. | -| grant | Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource. | -| grantConsumeMessages | Grant permissions to consume messages from a queue. | -| grantPurge | Grant an IAM principal permissions to purge all messages from the queue. | -| grantSendMessages | Grant access to send messages to a queue to the given identity. | -| metric | Return the given named metric for this Queue. | -| metricApproximateAgeOfOldestMessage | The approximate age of the oldest non-deleted message in the queue. | -| metricApproximateNumberOfMessagesDelayed | The number of messages in the queue that are delayed and not available for reading immediately. | -| metricApproximateNumberOfMessagesNotVisible | The number of messages that are in flight. | -| metricApproximateNumberOfMessagesVisible | The number of messages available for retrieval from the queue. | -| metricNumberOfEmptyReceives | The number of ReceiveMessage API calls that did not return a message. | -| metricNumberOfMessagesDeleted | The number of messages deleted from the queue. | -| metricNumberOfMessagesReceived | The number of messages returned by calls to the ReceiveMessage action. | -| metricNumberOfMessagesSent | The number of messages added to a queue. | -| metricSentMessageSize | The size of messages added to a queue. | -| alarmApproximateAgeOfOldestMessage | Creates an alarm that watches the age of the oldest message in the queue. | -| alarmApproximateNumberOfMessagesNotVisible | Creates an alarm that watches the number of messages that are in flight. | -| alarmApproximateNumberOfMessagesVisible | Creates an alarm that watches the number of messages that are visible in the queue. | -| alarmNumberOfMessagesSent | Creates an alarm that watches the number of messages that are sent. | -| applyRecommendedAlarms | Creates the recommended alarms for an SQS queue. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -5769,7 +10203,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -5785,394 +10219,500 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addToResourcePolicy` +##### `addAlarmAction` ```typescript -public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult +public addAlarmAction(actions: IAlarmAction): void ``` -Adds a statement to the IAM resource policy associated with this queue. +Trigger this action if the alarm fires. -If this queue was created in this stack (`new Queue`), a queue policy -will be automatically created upon the first call to `addToPolicy`. If -the queue is imported (`Queue.import`), then this is a no-op. +Typically SnsAction or AutoScalingAction. -###### `statement`Required +###### `actions`Required -- *Type:* aws-cdk-lib.aws_iam.PolicyStatement +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `grant` +##### `addInsufficientDataAction` ```typescript -public grant(grantee: IGrantable, actions: string): Grant +public addInsufficientDataAction(actions: IAlarmAction): void ``` -Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource. +Trigger this action if there is insufficient data to evaluate the alarm. -###### `grantee`Required +Typically SnsAction or AutoScalingAction. -- *Type:* aws-cdk-lib.aws_iam.IGrantable +###### `actions`Required -Principal to grant right to. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -###### `actions`Required +##### `addOkAction` -- *Type:* string +```typescript +public addOkAction(actions: IAlarmAction): void +``` -The actions to grant. +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `grantConsumeMessages` +##### `renderAlarmRule` ```typescript -public grantConsumeMessages(grantee: IGrantable): Grant +public renderAlarmRule(): string ``` -Grant permissions to consume messages from a queue. +AlarmRule indicating ALARM state for Alarm. -This will grant the following permissions: +##### `toAnnotation` - - sqs:ChangeMessageVisibility - - sqs:DeleteMessage - - sqs:ReceiveMessage - - sqs:GetQueueAttributes - - sqs:GetQueueUrl +```typescript +public toAnnotation(): HorizontalAnnotation +``` -If encryption is used, permission to use the key to decrypt the contents of the queue will also be granted to the same principal. +Turn this alarm into a horizontal annotation. -This will grant the following KMS permissions: +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. - - kms:Decrypt +This might be useful if: -###### `grantee`Required +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. -- *Type:* aws-cdk-lib.aws_iam.IGrantable +- You want to show an Alarm line in a graph with multiple metrics in it. -Principal to grant consume rights to. +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### `grantPurge` +##### ~~`isConstruct`~~ ```typescript -public grantPurge(grantee: IGrantable): Grant +import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceDatabaseConnectionsAlarm.isConstruct(x: any) ``` -Grant an IAM principal permissions to purge all messages from the queue. +Checks if `x` is a construct. -This will grant the following permissions: +###### `x`Required - - sqs:PurgeQueue - - sqs:GetQueueAttributes - - sqs:GetQueueUrl +- *Type:* any -###### `grantee`Required +Any object. -- *Type:* aws-cdk-lib.aws_iam.IGrantable +--- + +##### `isOwnedResource` + +```typescript +import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceDatabaseConnectionsAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceDatabaseConnectionsAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceDatabaseConnectionsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string -Principal to grant send rights to. +The construct's name. --- -##### `grantSendMessages` +###### `alarmArn`Required -```typescript -public grantSendMessages(grantee: IGrantable): Grant -``` +- *Type:* string -Grant access to send messages to a queue to the given identity. +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). -This will grant the following permissions: +--- - - sqs:SendMessage - - sqs:GetQueueAttributes - - sqs:GetQueueUrl +##### `fromAlarmName` -If encryption is used, permission to use the key to encrypt/decrypt the contents of the queue will also be granted to the same principal. +```typescript +import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -This will grant the following KMS permissions: +RdsInstanceDatabaseConnectionsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` - - kms:Decrypt - - kms:Encrypt - - kms:ReEncrypt* - - kms:GenerateDataKey* +Import an existing CloudWatch alarm provided an Name. -###### `grantee`Required +###### `scope`Required -- *Type:* aws-cdk-lib.aws_iam.IGrantable +- *Type:* constructs.Construct -Principal to grant send rights to. +The parent creating construct (usually `this`). --- -##### `metric` +###### `id`Required -```typescript -public metric(metricName: string, props?: MetricOptions): Metric -``` +- *Type:* string -Return the given named metric for this Queue. +The construct's name. -###### `metricName`Required +--- + +###### `alarmName`Required - *Type:* string +Alarm Name. + --- -###### `props`Optional +#### Properties -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `metricApproximateAgeOfOldestMessage` +##### `node`Required ```typescript -public metricApproximateAgeOfOldestMessage(props?: MetricOptions): Metric +public readonly node: Node; ``` -The approximate age of the oldest non-deleted message in the queue. - -Maximum over 5 minutes - -###### `props`Optional +- *Type:* constructs.Node -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The tree node. --- -##### `metricApproximateNumberOfMessagesDelayed` +##### `env`Required ```typescript -public metricApproximateNumberOfMessagesDelayed(props?: MetricOptions): Metric +public readonly env: ResourceEnvironment; ``` -The number of messages in the queue that are delayed and not available for reading immediately. - -Maximum over 5 minutes +- *Type:* aws-cdk-lib.ResourceEnvironment -###### `props`Optional +The environment this resource belongs to. -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. --- -##### `metricApproximateNumberOfMessagesNotVisible` +##### `stack`Required ```typescript -public metricApproximateNumberOfMessagesNotVisible(props?: MetricOptions): Metric +public readonly stack: Stack; ``` -The number of messages that are in flight. - -Maximum over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.Stack -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The stack in which this resource is defined. --- -##### `metricApproximateNumberOfMessagesVisible` +##### `alarmArn`Required ```typescript -public metricApproximateNumberOfMessagesVisible(props?: MetricOptions): Metric +public readonly alarmArn: string; ``` -The number of messages available for retrieval from the queue. - -Maximum over 5 minutes - -###### `props`Optional +- *Type:* string -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +ARN of this alarm. --- -##### `metricNumberOfEmptyReceives` +##### `alarmName`Required ```typescript -public metricNumberOfEmptyReceives(props?: MetricOptions): Metric +public readonly alarmName: string; ``` -The number of ReceiveMessage API calls that did not return a message. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* string -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +Name of this alarm. --- -##### `metricNumberOfMessagesDeleted` +##### `metric`Required ```typescript -public metricNumberOfMessagesDeleted(props?: MetricOptions): Metric +public readonly metric: IMetric; ``` -The number of messages deleted from the queue. +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -Sum over 5 minutes +The metric object this alarm was based on. -###### `props`Optional +--- -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions ---- +### RdsInstanceDbLoadAlarm -##### `metricNumberOfMessagesReceived` +An alarm that monitors the number of concurrent active sessions on the database. + +This alarm helps to monitor high DB load. If the number of processes exceed the number of vCPUs, +the processes start queuing. When the queuing increases, the performance is impacted. + +The alarm is triggered when the number of active sessions for the database is +greater than threshold. + +#### Initializers ```typescript -public metricNumberOfMessagesReceived(props?: MetricOptions): Metric +import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new RdsInstanceDbLoadAlarm(scope: Construct, id: string, props: RdsInstanceDbLoadAlarmProps) ``` -The number of messages returned by calls to the ReceiveMessage action. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceDbLoadAlarmProps | *No description.* | -Sum over 5 minutes +--- -###### `props`Optional +##### `scope`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +- *Type:* constructs.Construct --- -##### `metricNumberOfMessagesSent` - -```typescript -public metricNumberOfMessagesSent(props?: MetricOptions): Metric -``` +##### `id`Required -The number of messages added to a queue. +- *Type:* string -Sum over 5 minutes +--- -###### `props`Optional +##### `props`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +- *Type:* RdsInstanceDbLoadAlarmProps --- -##### `metricSentMessageSize` - -```typescript -public metricSentMessageSize(props?: MetricOptions): Metric -``` +#### Methods -The size of messages added to a queue. +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | -Average over 5 minutes +--- -###### `props`Optional +##### `toString` -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +```typescript +public toString(): string +``` ---- +Returns a string representation of this construct. -##### `alarmApproximateAgeOfOldestMessage` +##### `applyRemovalPolicy` ```typescript -public alarmApproximateAgeOfOldestMessage(props: SqsApproximateAgeOfOldestMessageAlarmConfig): SqsApproximateAgeOfOldestMessageAlarm +public applyRemovalPolicy(policy: RemovalPolicy): void ``` -Creates an alarm that watches the age of the oldest message in the queue. +Apply the given removal policy to this resource. -###### `props`Required +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. -- *Type:* SqsApproximateAgeOfOldestMessageAlarmConfig +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy --- -##### `alarmApproximateNumberOfMessagesNotVisible` +##### `addAlarmAction` ```typescript -public alarmApproximateNumberOfMessagesNotVisible(props: SqsApproximateNumberOfMessagesNotVisibleAlarmConfig): SqsApproximateNumberOfMessagesNotVisibleAlarm +public addAlarmAction(actions: IAlarmAction): void ``` -Creates an alarm that watches the number of messages that are in flight. +Trigger this action if the alarm fires. -###### `props`Required +Typically SnsAction or AutoScalingAction. -- *Type:* SqsApproximateNumberOfMessagesNotVisibleAlarmConfig +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `alarmApproximateNumberOfMessagesVisible` +##### `addInsufficientDataAction` ```typescript -public alarmApproximateNumberOfMessagesVisible(props: SqsApproximateNumberOfMessagesVisibleAlarmConfig): SqsApproximateNumberOfMessagesVisibleAlarm +public addInsufficientDataAction(actions: IAlarmAction): void ``` -Creates an alarm that watches the number of messages that are visible in the queue. +Trigger this action if there is insufficient data to evaluate the alarm. -###### `props`Required +Typically SnsAction or AutoScalingAction. -- *Type:* SqsApproximateNumberOfMessagesVisibleAlarmConfig +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `alarmNumberOfMessagesSent` +##### `addOkAction` ```typescript -public alarmNumberOfMessagesSent(props?: SqsNumberOfMessagesSentAlarmConfig): SqsNumberOfMessagesSentAlarm +public addOkAction(actions: IAlarmAction): void ``` -Creates an alarm that watches the number of messages that are sent. +Trigger this action if the alarm returns from breaching state into ok state. + +Typically SnsAction or AutoScalingAction. + +###### `actions`Required + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction + +--- -###### `props`Optional +##### `renderAlarmRule` -- *Type:* SqsNumberOfMessagesSentAlarmConfig +```typescript +public renderAlarmRule(): string +``` ---- +AlarmRule indicating ALARM state for Alarm. -##### `applyRecommendedAlarms` +##### `toAnnotation` ```typescript -public applyRecommendedAlarms(props: SqsRecommendedAlarmsConfig): void +public toAnnotation(): HorizontalAnnotation ``` -Creates the recommended alarms for an SQS queue. +Turn this alarm into a horizontal annotation. -###### `props`Required +This is useful if you want to represent an Alarm in a non-AlarmWidget. +An `AlarmWidget` can directly show an alarm, but it can only show a +single alarm and no other metrics. Instead, you can convert the alarm to +a HorizontalAnnotation and add it as an annotation to another graph. -- *Type:* SqsRecommendedAlarmsConfig +This might be useful if: ---- +- You want to show multiple alarms inside a single graph, for example if + you have both a "small margin/long period" alarm as well as a + "large margin/short period" alarm. + +- You want to show an Alarm line in a graph with multiple metrics in it. #### Static Functions | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromQueueArn | Import an existing SQS queue provided an ARN. | -| fromQueueAttributes | Import an existing queue. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Queue.isConstruct(x: any) +RdsInstanceDbLoadAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -6180,57 +10720,57 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Queue.isOwnedResource(construct: IConstruct) +RdsInstanceDbLoadAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Queue.isResource(construct: IConstruct) +RdsInstanceDbLoadAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromQueueArn` +##### `fromAlarmArn` ```typescript -import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Queue.fromQueueArn(scope: Construct, id: string, queueArn: string) +RdsInstanceDbLoadAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` -Import an existing SQS queue provided an ARN. +Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct -The parent creating construct. +The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -6238,39 +10778,45 @@ The construct's name. --- -###### `queueArn`Required +###### `alarmArn`Required - *Type:* string -queue ARN (i.e. arn:aws:sqs:us-east-2:444455556666:queue1). +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromQueueAttributes` +##### `fromAlarmName` ```typescript -import { Queue } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Queue.fromQueueAttributes(scope: Construct, id: string, attrs: QueueAttributes) +RdsInstanceDbLoadAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` -Import an existing queue. +Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct +The parent creating construct (usually `this`). + --- -###### `id`Required +###### `id`Required - *Type:* string +The construct's name. + --- -###### `attrs`Required +###### `alarmName`Required -- *Type:* aws-cdk-lib.aws_sqs.QueueAttributes +- *Type:* string + +Alarm Name. --- @@ -6278,20 +10824,16 @@ Import an existing queue. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| fifo | boolean | Whether this queue is an Amazon SQS FIFO queue. | -| queueArn | string | The ARN of this queue. | -| queueName | string | The name of this queue. | -| queueUrl | string | The URL of this queue. | -| encryptionMasterKey | aws-cdk-lib.aws_kms.IKey | If this queue is encrypted, this is the KMS key. | -| encryptionType | aws-cdk-lib.aws_sqs.QueueEncryption | Whether the contents of the queue are encrypted, and by what type of key. | -| deadLetterQueue | aws-cdk-lib.aws_sqs.DeadLetterQueue | If this queue is configured with a dead-letter queue, this is the dead-letter queue settings. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -6303,7 +10845,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -6322,7 +10864,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -6334,132 +10876,82 @@ The stack in which this resource is defined. --- -##### `fifo`Required - -```typescript -public readonly fifo: boolean; -``` - -- *Type:* boolean - -Whether this queue is an Amazon SQS FIFO queue. - -If false, this is a standard queue. - ---- - -##### `queueArn`Required - -```typescript -public readonly queueArn: string; -``` - -- *Type:* string - -The ARN of this queue. - ---- - -##### `queueName`Required +##### `alarmArn`Required ```typescript -public readonly queueName: string; +public readonly alarmArn: string; ``` - *Type:* string -The name of this queue. +ARN of this alarm. --- -##### `queueUrl`Required +##### `alarmName`Required ```typescript -public readonly queueUrl: string; +public readonly alarmName: string; ``` - *Type:* string -The URL of this queue. - ---- - -##### `encryptionMasterKey`Optional - -```typescript -public readonly encryptionMasterKey: IKey; -``` - -- *Type:* aws-cdk-lib.aws_kms.IKey - -If this queue is encrypted, this is the KMS key. - ---- - -##### `encryptionType`Optional - -```typescript -public readonly encryptionType: QueueEncryption; -``` - -- *Type:* aws-cdk-lib.aws_sqs.QueueEncryption - -Whether the contents of the queue are encrypted, and by what type of key. +Name of this alarm. --- -##### `deadLetterQueue`Optional +##### `metric`Required ```typescript -public readonly deadLetterQueue: DeadLetterQueue; +public readonly metric: IMetric; ``` -- *Type:* aws-cdk-lib.aws_sqs.DeadLetterQueue +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -If this queue is configured with a dead-letter queue, this is the dead-letter queue settings. +The metric object this alarm was based on. --- -### RdsAuroraBinLogReplicationLagAlarm +### RdsInstanceFreeableMemoryAlarm -An alarm that monitors the error state of Aurora writer instance replication. +An alarm that monitors the amount of available memory (RAM) on the RDS instance. -This alarm is used to detect whether the writer instance is in an error state and can’t replicate the source. +This alarm is used to help prevent running out of memory which can result in rejected connections. -The alarm is triggered when the value is less than or equal to threshold. +The alarm is triggered when the percentage of available memory is less than threshold. -#### Initializers +#### Initializers ```typescript -import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsAuroraBinLogReplicationLagAlarm(scope: Construct, id: string, props: RdsAuroraBinLogReplicationLagAlarmProps) +new RdsInstanceFreeableMemoryAlarm(scope: Construct, id: string, props: RdsInstanceFreeableMemoryAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsAuroraBinLogReplicationLagAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceFreeableMemoryAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsAuroraBinLogReplicationLagAlarmProps +- *Type:* RdsInstanceFreeableMemoryAlarmProps --- @@ -6467,17 +10959,17 @@ new RdsAuroraBinLogReplicationLagAlarm(scope: Construct, id: string, props: RdsA | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -6485,7 +10977,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -6501,13 +10993,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -6517,13 +11009,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -6533,13 +11025,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -6549,13 +11041,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -6563,7 +11055,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -6588,25 +11080,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraBinLogReplicationLagAlarm.isConstruct(x: any) +RdsInstanceFreeableMemoryAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -6614,49 +11106,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraBinLogReplicationLagAlarm.isOwnedResource(construct: IConstruct) +RdsInstanceFreeableMemoryAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraBinLogReplicationLagAlarm.isResource(construct: IConstruct) +RdsInstanceFreeableMemoryAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraBinLogReplicationLagAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +RdsInstanceFreeableMemoryAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -6664,7 +11156,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -6672,7 +11164,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -6680,17 +11172,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsAuroraBinLogReplicationLagAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraBinLogReplicationLagAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +RdsInstanceFreeableMemoryAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -6698,7 +11190,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -6706,7 +11198,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -6718,16 +11210,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -6739,7 +11231,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -6758,7 +11250,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -6770,7 +11262,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -6782,7 +11274,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -6794,7 +11286,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -6807,193 +11299,64 @@ The metric object this alarm was based on. --- -### RdsAuroraRecommendedAlarms - -A construct that creates recommended alarms for an RDS cluster. - -> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS) - -#### Initializers - -```typescript -import { RdsAuroraRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -new RdsAuroraRecommendedAlarms(scope: Construct, id: string, props: RdsAuroraRecommendedAlarmsProps) -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsAuroraRecommendedAlarmsProps | *No description.* | - ---- - -##### `scope`Required - -- *Type:* constructs.Construct - ---- - -##### `id`Required - -- *Type:* string - ---- - -##### `props`Required - -- *Type:* RdsAuroraRecommendedAlarmsProps - ---- - -#### Methods - -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | - ---- - -##### `toString` - -```typescript -public toString(): string -``` - -Returns a string representation of this construct. - -#### Static Functions - -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | - ---- - -##### ~~`isConstruct`~~ - -```typescript -import { RdsAuroraRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsAuroraRecommendedAlarms.isConstruct(x: any) -``` - -Checks if `x` is a construct. - -###### `x`Required - -- *Type:* any - -Any object. - ---- - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| alarmAuroraBinLogReplicationLag | RdsAuroraBinLogReplicationLagAlarm | The Bin Log Replication lag alarm for the database cluster. | -| alarmAuroraVolumeBytesLeftTotal | RdsAuroraVolumeBytesLeftTotalAlarm | The AuroraVolumeBytesLeftTotal alarm for the database cluster. | - ---- - -##### `node`Required - -```typescript -public readonly node: Node; -``` - -- *Type:* constructs.Node - -The tree node. - ---- - -##### `alarmAuroraBinLogReplicationLag`Optional - -```typescript -public readonly alarmAuroraBinLogReplicationLag: RdsAuroraBinLogReplicationLagAlarm; -``` - -- *Type:* RdsAuroraBinLogReplicationLagAlarm - -The Bin Log Replication lag alarm for the database cluster. - ---- - -##### `alarmAuroraVolumeBytesLeftTotal`Optional - -```typescript -public readonly alarmAuroraVolumeBytesLeftTotal: RdsAuroraVolumeBytesLeftTotalAlarm; -``` - -- *Type:* RdsAuroraVolumeBytesLeftTotalAlarm - -The AuroraVolumeBytesLeftTotal alarm for the database cluster. - ---- - - -### RdsAuroraVolumeBytesLeftTotalAlarm +### RdsInstanceFreeLocalStorageAlarm -An alarm that monitors the remaining available space (in bytes) for the cluster volume. +An alarm that monitors the amount of available local storage space for an Aurora instance used for temporary files. -This alarm is used to detect how close the Aurora cluster is to the volume size limit. This -alarm can prevent an out-of-space error that occurs when your cluster runs out of space. +This alarm is used to detect how close the Aurora DB instance is to reaching the local storage limit. +This alarm can prevent an out-of-space error that occurs when your DB instance runs out of local storage. -The alarm is triggered when the remaining available space (in bytes) is less than threshold. +The alarm is triggered when the amount of available local storage space (bytes) is less than threshold. -#### Initializers +#### Initializers ```typescript -import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsAuroraVolumeBytesLeftTotalAlarm(scope: Construct, id: string, props: RdsAuroraVolumeBytesLeftTotalAlarmProps) +new RdsInstanceFreeLocalStorageAlarm(scope: Construct, id: string, props: RdsInstanceFreeLocalStorageAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsAuroraVolumeBytesLeftTotalAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceFreeLocalStorageAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsAuroraVolumeBytesLeftTotalAlarmProps +- *Type:* RdsInstanceFreeLocalStorageAlarmProps --- -#### Methods - -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | - +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | + --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -7001,7 +11364,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -7017,13 +11380,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -7033,13 +11396,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -7049,13 +11412,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -7065,13 +11428,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -7079,7 +11442,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -7104,25 +11467,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraVolumeBytesLeftTotalAlarm.isConstruct(x: any) +RdsInstanceFreeLocalStorageAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -7130,49 +11493,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraVolumeBytesLeftTotalAlarm.isOwnedResource(construct: IConstruct) +RdsInstanceFreeLocalStorageAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraVolumeBytesLeftTotalAlarm.isResource(construct: IConstruct) +RdsInstanceFreeLocalStorageAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraVolumeBytesLeftTotalAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +RdsInstanceFreeLocalStorageAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -7180,7 +11543,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -7188,7 +11551,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -7196,17 +11559,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsAuroraVolumeBytesLeftTotalAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsAuroraVolumeBytesLeftTotalAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +RdsInstanceFreeLocalStorageAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -7214,7 +11577,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -7222,7 +11585,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -7234,16 +11597,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -7255,7 +11618,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -7274,7 +11637,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -7286,7 +11649,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -7298,7 +11661,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -7310,7 +11673,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -7323,46 +11686,46 @@ The metric object this alarm was based on. --- -### RdsInstanceCpuUtilizationAlarm +### RdsInstanceFreeStorageSpaceAlarm -An alarm that monitors CPU utilization for an RDS instance. +An alarm that monitors the amount of available storage space for an Aurora instance. -This alarm is used to detect consistent high CPU utilization in order to prevent very -high response time and time-outs. +This alarm helps prevent storage full issues. This can prevent downtime that occurs when your database +instance runs out of storage. -The alarm is triggered when the CPU utilization exceeds the % threshold. +The alarm is triggered when the amount of available storage space (bytes) is less than threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceCpuUtilizationAlarm(scope: Construct, id: string, props: RdsInstanceCpuUtilizationAlarmProps) +new RdsInstanceFreeStorageSpaceAlarm(scope: Construct, id: string, props: RdsInstanceFreeStorageSpaceAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceCpuUtilizationAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceFreeStorageSpaceAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceCpuUtilizationAlarmProps +- *Type:* RdsInstanceFreeStorageSpaceAlarmProps --- @@ -7370,17 +11733,17 @@ new RdsInstanceCpuUtilizationAlarm(scope: Construct, id: string, props: RdsInsta | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -7388,7 +11751,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -7404,13 +11767,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -7420,13 +11783,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -7436,13 +11799,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -7452,13 +11815,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -7466,7 +11829,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -7491,25 +11854,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceCpuUtilizationAlarm.isConstruct(x: any) +RdsInstanceFreeStorageSpaceAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -7517,49 +11880,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceCpuUtilizationAlarm.isOwnedResource(construct: IConstruct) +RdsInstanceFreeStorageSpaceAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceCpuUtilizationAlarm.isResource(construct: IConstruct) +RdsInstanceFreeStorageSpaceAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceCpuUtilizationAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +RdsInstanceFreeStorageSpaceAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -7567,7 +11930,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -7575,7 +11938,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -7583,17 +11946,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsInstanceCpuUtilizationAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceCpuUtilizationAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +RdsInstanceFreeStorageSpaceAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -7601,7 +11964,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -7609,7 +11972,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -7621,16 +11984,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -7642,7 +12005,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -7661,7 +12024,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -7673,7 +12036,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -7685,7 +12048,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -7697,7 +12060,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -7710,46 +12073,47 @@ The metric object this alarm was based on. --- -### RdsInstanceDatabaseConnectionsAlarm +### RdsInstanceReadLatencyAlarm -An alarm that monitors the number of client network connections to the database instance. +An alarm that monitors the average amount of time taken per disk read I/O operation. -This alarm is used to help prevent rejected connections when the maximum number of DB -connections is reached. +This alarm is used to detect high read latency. Database disks normally have a low read/write latency, +but they can have issues that can cause high latency operations. -The alarm is triggered when number of connections is greater than threshold. +The alarm is triggered when the average amount of time per disk read operation (in milliseconds) is +greater than threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceDatabaseConnectionsAlarm(scope: Construct, id: string, props: RdsInstanceDatabaseConnectionsAlarmProps) +new RdsInstanceReadLatencyAlarm(scope: Construct, id: string, props: RdsInstanceReadLatencyAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceDatabaseConnectionsAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceReadLatencyAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceDatabaseConnectionsAlarmProps +- *Type:* RdsInstanceReadLatencyAlarmProps --- @@ -7757,17 +12121,17 @@ new RdsInstanceDatabaseConnectionsAlarm(scope: Construct, id: string, props: Rds | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -7775,7 +12139,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -7791,13 +12155,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -7807,13 +12171,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -7823,13 +12187,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -7839,13 +12203,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -7853,7 +12217,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -7878,129 +12242,304 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | + +--- + +##### ~~`isConstruct`~~ + +```typescript +import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceReadLatencyAlarm.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceReadLatencyAlarm.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceReadLatencyAlarm.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromAlarmArn` + +```typescript +import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceReadLatencyAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +``` + +Import an existing CloudWatch alarm provided an ARN. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmArn`Required + +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). + +--- + +##### `fromAlarmName` + +```typescript +import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +RdsInstanceReadLatencyAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +``` + +Import an existing CloudWatch alarm provided an Name. + +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. --- -##### ~~`isConstruct`~~ +##### `alarmArn`Required ```typescript -import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceDatabaseConnectionsAlarm.isConstruct(x: any) +public readonly alarmArn: string; ``` -Checks if `x` is a construct. - -###### `x`Required - -- *Type:* any +- *Type:* string -Any object. +ARN of this alarm. --- -##### `isOwnedResource` +##### `alarmName`Required ```typescript -import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceDatabaseConnectionsAlarm.isOwnedResource(construct: IConstruct) +public readonly alarmName: string; ``` -Returns true if the construct was created by CDK, and false otherwise. - -###### `construct`Required +- *Type:* string -- *Type:* constructs.IConstruct +Name of this alarm. --- -##### `isResource` +##### `metric`Required ```typescript -import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceDatabaseConnectionsAlarm.isResource(construct: IConstruct) +public readonly metric: IMetric; ``` -Check whether the given construct is a Resource. - -###### `construct`Required +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -- *Type:* constructs.IConstruct +The metric object this alarm was based on. --- -##### `fromAlarmArn` + +### RdsInstanceRecommendedAlarms + +A construct that creates recommended alarms for an RDS cluster instance. + +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS) + +#### Initializers ```typescript -import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceDatabaseConnectionsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +new RdsInstanceRecommendedAlarms(scope: Construct, id: string, props: RdsInstanceRecommendedAlarmsProps) ``` -Import an existing CloudWatch alarm provided an ARN. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceRecommendedAlarmsProps | *No description.* | -###### `scope`Required +--- -- *Type:* constructs.Construct +##### `scope`Required -The parent creating construct (usually `this`). +- *Type:* constructs.Construct --- -###### `id`Required +##### `id`Required - *Type:* string -The construct's name. - --- -###### `alarmArn`Required +##### `props`Required -- *Type:* string +- *Type:* RdsInstanceRecommendedAlarmsProps -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | --- -##### `fromAlarmName` +##### `toString` ```typescript -import { RdsInstanceDatabaseConnectionsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceDatabaseConnectionsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +public toString(): string ``` -Import an existing CloudWatch alarm provided an Name. - -###### `scope`Required +Returns a string representation of this construct. -- *Type:* constructs.Construct +#### Static Functions -The parent creating construct (usually `this`). +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | --- -###### `id`Required +##### ~~`isConstruct`~~ -- *Type:* string +```typescript +import { RdsInstanceRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' -The construct's name. +RdsInstanceRecommendedAlarms.isConstruct(x: any) +``` ---- +Checks if `x` is a construct. -###### `alarmName`Required +###### `x`Required -- *Type:* string +- *Type:* any -Alarm Name. +Any object. --- @@ -8008,16 +12547,19 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| alarmCpuUtilization | RdsInstanceCpuUtilizationAlarm | The CpuUtilization alarm for the database instance. | +| alarmDatabaseConnections | RdsInstanceDatabaseConnectionsAlarm | The DatabaseConnections alarm for the database instance. | +| alarmDbLoad | RdsInstanceDbLoadAlarm | The DbLoad alarm for the database instance. | +| alarmFreeableMemory | RdsInstanceFreeableMemoryAlarm | The FreeableMemory alarm for the database instance. | +| alarmFreeLocalStorage | RdsInstanceFreeLocalStorageAlarm | The FreeLocalStorage alarm for the database instance. | +| alarmFreeStorageSpace | RdsInstanceFreeStorageSpaceAlarm | The FreeStorageSpace alarm for the database instance. | +| alarmReadLatency | RdsInstanceReadLatencyAlarm | The ReadLatency alarm for the database instance. | +| alarmWriteLatency | RdsInstanceWriteLatencyAlarm | The WriteLatency alarm for the database instance. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -8029,115 +12571,144 @@ The tree node. --- -##### `env`Required +##### `alarmCpuUtilization`Optional ```typescript -public readonly env: ResourceEnvironment; +public readonly alarmCpuUtilization: RdsInstanceCpuUtilizationAlarm; ``` -- *Type:* aws-cdk-lib.ResourceEnvironment +- *Type:* RdsInstanceCpuUtilizationAlarm -The environment this resource belongs to. +The CpuUtilization alarm for the database instance. -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +--- + +##### `alarmDatabaseConnections`Optional + +```typescript +public readonly alarmDatabaseConnections: RdsInstanceDatabaseConnectionsAlarm; +``` + +- *Type:* RdsInstanceDatabaseConnectionsAlarm + +The DatabaseConnections alarm for the database instance. --- -##### `stack`Required +##### `alarmDbLoad`Optional ```typescript -public readonly stack: Stack; +public readonly alarmDbLoad: RdsInstanceDbLoadAlarm; ``` -- *Type:* aws-cdk-lib.Stack +- *Type:* RdsInstanceDbLoadAlarm -The stack in which this resource is defined. +The DbLoad alarm for the database instance. --- -##### `alarmArn`Required +##### `alarmFreeableMemory`Optional ```typescript -public readonly alarmArn: string; +public readonly alarmFreeableMemory: RdsInstanceFreeableMemoryAlarm; ``` -- *Type:* string +- *Type:* RdsInstanceFreeableMemoryAlarm -ARN of this alarm. +The FreeableMemory alarm for the database instance. --- -##### `alarmName`Required +##### `alarmFreeLocalStorage`Optional ```typescript -public readonly alarmName: string; +public readonly alarmFreeLocalStorage: RdsInstanceFreeLocalStorageAlarm; ``` -- *Type:* string +- *Type:* RdsInstanceFreeLocalStorageAlarm -Name of this alarm. +The FreeLocalStorage alarm for the database instance. --- -##### `metric`Required +##### `alarmFreeStorageSpace`Optional ```typescript -public readonly metric: IMetric; +public readonly alarmFreeStorageSpace: RdsInstanceFreeStorageSpaceAlarm; ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +- *Type:* RdsInstanceFreeStorageSpaceAlarm -The metric object this alarm was based on. +The FreeStorageSpace alarm for the database instance. --- +##### `alarmReadLatency`Optional -### RdsInstanceDbLoadAlarm +```typescript +public readonly alarmReadLatency: RdsInstanceReadLatencyAlarm; +``` -An alarm that monitors the number of concurrent active sessions on the database. +- *Type:* RdsInstanceReadLatencyAlarm -This alarm helps to monitor high DB load. If the number of processes exceed the number of vCPUs, -the processes start queuing. When the queuing increases, the performance is impacted. +The ReadLatency alarm for the database instance. -The alarm is triggered when the number of active sessions for the database is +--- + +##### `alarmWriteLatency`Optional + +```typescript +public readonly alarmWriteLatency: RdsInstanceWriteLatencyAlarm; +``` + +- *Type:* RdsInstanceWriteLatencyAlarm + +The WriteLatency alarm for the database instance. + +--- + + +### RdsInstanceWriteLatencyAlarm + +An alarm that monitors the average amount of time taken per disk write I/O operation. + +This alarm is used to detect high write latency. Database disks normally have a low read/write latency, +but they can have issues that can cause high latency operations. + +The alarm is triggered when the average amount of time per disk write operation (in milliseconds) is greater than threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceDbLoadAlarm(scope: Construct, id: string, props: RdsInstanceDbLoadAlarmProps) +new RdsInstanceWriteLatencyAlarm(scope: Construct, id: string, props: RdsInstanceWriteLatencyAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceDbLoadAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | RdsInstanceWriteLatencyAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceDbLoadAlarmProps +- *Type:* RdsInstanceWriteLatencyAlarmProps --- @@ -8145,17 +12716,17 @@ new RdsInstanceDbLoadAlarm(scope: Construct, id: string, props: RdsInstanceDbLoa | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -8163,7 +12734,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -8179,13 +12750,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -8195,13 +12766,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -8211,13 +12782,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -8227,13 +12798,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -8241,7 +12812,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -8266,25 +12837,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceDbLoadAlarm.isConstruct(x: any) +RdsInstanceWriteLatencyAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -8292,49 +12863,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceDbLoadAlarm.isOwnedResource(construct: IConstruct) +RdsInstanceWriteLatencyAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceDbLoadAlarm.isResource(construct: IConstruct) +RdsInstanceWriteLatencyAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceDbLoadAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +RdsInstanceWriteLatencyAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -8342,7 +12913,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -8350,7 +12921,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -8358,17 +12929,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsInstanceDbLoadAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceDbLoadAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +RdsInstanceWriteLatencyAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -8376,7 +12947,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -8384,7 +12955,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -8396,16 +12967,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -8417,7 +12988,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -8436,7 +13007,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -8448,7 +13019,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -8460,7 +13031,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -8472,7 +13043,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -8485,45 +13056,47 @@ The metric object this alarm was based on. --- -### RdsInstanceFreeableMemoryAlarm +### S3Bucket4xxErrorsAlarm -An alarm that monitors the amount of available memory (RAM) on the RDS instance. +An alarm that monitors the 4xx errors for an S3 bucket. -This alarm is used to help prevent running out of memory which can result in rejected connections. +This alarm is used to create a baseline for typical 4xx error +rates so that you can look into any abnormalities that might +indicate a setup issue. -The alarm is triggered when the percentage of available memory is less than threshold. +The alarm is triggered when the 4xx error rate exceeds the % threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceFreeableMemoryAlarm(scope: Construct, id: string, props: RdsInstanceFreeableMemoryAlarmProps) +new S3Bucket4xxErrorsAlarm(scope: IConstruct, id: string, props: S3Bucket4xxErrorsAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceFreeableMemoryAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | S3Bucket4xxErrorsAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.Construct +- *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceFreeableMemoryAlarmProps +- *Type:* S3Bucket4xxErrorsAlarmProps --- @@ -8531,17 +13104,17 @@ new RdsInstanceFreeableMemoryAlarm(scope: Construct, id: string, props: RdsInsta | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -8549,7 +13122,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -8565,13 +13138,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -8581,13 +13154,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -8597,13 +13170,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -8613,13 +13186,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -8627,7 +13200,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -8652,25 +13225,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeableMemoryAlarm.isConstruct(x: any) +S3Bucket4xxErrorsAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -8678,49 +13251,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeableMemoryAlarm.isOwnedResource(construct: IConstruct) +S3Bucket4xxErrorsAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeableMemoryAlarm.isResource(construct: IConstruct) +S3Bucket4xxErrorsAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeableMemoryAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +S3Bucket4xxErrorsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -8728,7 +13301,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -8736,7 +13309,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -8744,17 +13317,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsInstanceFreeableMemoryAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeableMemoryAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +S3Bucket4xxErrorsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -8762,7 +13335,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -8770,7 +13343,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -8782,16 +13355,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -8803,7 +13376,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -8822,7 +13395,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -8834,7 +13407,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -8846,7 +13419,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -8858,7 +13431,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -8871,46 +13444,46 @@ The metric object this alarm was based on. --- -### RdsInstanceFreeLocalStorageAlarm +### S3Bucket5xxErrorsAlarm -An alarm that monitors the amount of available local storage space for an Aurora instance used for temporary files. +An alarm that monitors the 5xx errors for an S3 bucket. -This alarm is used to detect how close the Aurora DB instance is to reaching the local storage limit. -This alarm can prevent an out-of-space error that occurs when your DB instance runs out of local storage. +This alarm can help to detect if the application is +experiencing issues due to 5xx errors. -The alarm is triggered when the amount of available local storage space (bytes) is less than threshold. +The alarm is triggered when the 5xx error rate exceeds the % threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceFreeLocalStorageAlarm(scope: Construct, id: string, props: RdsInstanceFreeLocalStorageAlarmProps) +new S3Bucket5xxErrorsAlarm(scope: IConstruct, id: string, props: S3Bucket5xxErrorsAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceFreeLocalStorageAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | S3Bucket5xxErrorsAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.Construct +- *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceFreeLocalStorageAlarmProps +- *Type:* S3Bucket5xxErrorsAlarmProps --- @@ -8918,17 +13491,17 @@ new RdsInstanceFreeLocalStorageAlarm(scope: Construct, id: string, props: RdsIns | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -8936,7 +13509,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -8952,13 +13525,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -8968,13 +13541,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -8984,13 +13557,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -9000,13 +13573,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -9014,7 +13587,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -9039,25 +13612,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeLocalStorageAlarm.isConstruct(x: any) +S3Bucket5xxErrorsAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -9065,49 +13638,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeLocalStorageAlarm.isOwnedResource(construct: IConstruct) +S3Bucket5xxErrorsAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeLocalStorageAlarm.isResource(construct: IConstruct) +S3Bucket5xxErrorsAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeLocalStorageAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +S3Bucket5xxErrorsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -9115,7 +13688,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -9123,7 +13696,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -9131,173 +13704,307 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsInstanceFreeLocalStorageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeLocalStorageAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +S3Bucket5xxErrorsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required + +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). + +--- + +###### `id`Required + +- *Type:* string + +The construct's name. + +--- + +###### `alarmName`Required + +- *Type:* string + +Alarm Name. + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `alarmArn`Required + +```typescript +public readonly alarmArn: string; +``` + +- *Type:* string + +ARN of this alarm. + +--- + +##### `alarmName`Required + +```typescript +public readonly alarmName: string; +``` + +- *Type:* string + +Name of this alarm. + +--- + +##### `metric`Required + +```typescript +public readonly metric: IMetric; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric + +The metric object this alarm was based on. + +--- + + +### S3RecommendedAlarms + +A construct that creates the recommended alarms for an S3 bucket. + +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#S3](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#S3) + +#### Initializers + +```typescript +import { S3RecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new S3RecommendedAlarms(scope: Construct, id: string, props: S3RecommendedAlarmsProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | S3RecommendedAlarmsProps | *No description.* | + +--- + +##### `scope`Required - *Type:* constructs.Construct -The parent creating construct (usually `this`). - --- -###### `id`Required +##### `id`Required - *Type:* string -The construct's name. - --- -###### `alarmName`Required - -- *Type:* string +##### `props`Required -Alarm Name. +- *Type:* S3RecommendedAlarmsProps --- -#### Properties +#### Methods -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | --- -##### `node`Required +##### `toString` ```typescript -public readonly node: Node; +public toString(): string ``` -- *Type:* constructs.Node +Returns a string representation of this construct. -The tree node. +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | --- -##### `env`Required +##### ~~`isConstruct`~~ ```typescript -public readonly env: ResourceEnvironment; -``` +import { S3RecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' -- *Type:* aws-cdk-lib.ResourceEnvironment +S3RecommendedAlarms.isConstruct(x: any) +``` -The environment this resource belongs to. +Checks if `x` is a construct. -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +###### `x`Required ---- +- *Type:* any -##### `stack`Required +Any object. -```typescript -public readonly stack: Stack; -``` +--- -- *Type:* aws-cdk-lib.Stack +#### Properties -The stack in which this resource is defined. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| alarm4xxErrors | S3Bucket4xxErrorsAlarm | The 4xx errors alarm. | +| alarm5xxErrors | S3Bucket5xxErrorsAlarm | The 5xx errors alarm. | --- -##### `alarmArn`Required +##### `node`Required ```typescript -public readonly alarmArn: string; +public readonly node: Node; ``` -- *Type:* string +- *Type:* constructs.Node -ARN of this alarm. +The tree node. --- -##### `alarmName`Required +##### `alarm4xxErrors`Optional ```typescript -public readonly alarmName: string; +public readonly alarm4xxErrors: S3Bucket4xxErrorsAlarm; ``` -- *Type:* string +- *Type:* S3Bucket4xxErrorsAlarm -Name of this alarm. +The 4xx errors alarm. --- -##### `metric`Required +##### `alarm5xxErrors`Optional ```typescript -public readonly metric: IMetric; +public readonly alarm5xxErrors: S3Bucket5xxErrorsAlarm; ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +- *Type:* S3Bucket5xxErrorsAlarm -The metric object this alarm was based on. +The 5xx errors alarm. --- -### RdsInstanceFreeStorageSpaceAlarm +### SnsNumberOfMessagesPublishedAlarm -An alarm that monitors the amount of available storage space for an Aurora instance. +An alarm that monitors the number of messages published to an SNS topic. -This alarm helps prevent storage full issues. This can prevent downtime that occurs when your database -instance runs out of storage. +This alarm helps you proactively monitor and detect significant drops in +notification publishing. This helps you identify potential issues with +your application or business processes, so that you can take appropriate +actions to maintain the expected flow of notifications. You should create +this alarm if you expect your system to have a minimum traffic that it +is serving. -The alarm is triggered when the amount of available storage space (bytes) is less than threshold. +The alarm is triggered when the number of messages published to the topic +is less than the specified threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceFreeStorageSpaceAlarm(scope: Construct, id: string, props: RdsInstanceFreeStorageSpaceAlarmProps) +new SnsNumberOfMessagesPublishedAlarm(scope: IConstruct, id: string, props: SnsNumberOfMessagesPublishedAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceFreeStorageSpaceAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SnsNumberOfMessagesPublishedAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.Construct +- *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceFreeStorageSpaceAlarmProps +- *Type:* SnsNumberOfMessagesPublishedAlarmProps --- @@ -9305,17 +14012,17 @@ new RdsInstanceFreeStorageSpaceAlarm(scope: Construct, id: string, props: RdsIns | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -9323,7 +14030,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -9339,13 +14046,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -9355,13 +14062,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -9371,13 +14078,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -9387,13 +14094,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -9401,7 +14108,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -9426,25 +14133,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeStorageSpaceAlarm.isConstruct(x: any) +SnsNumberOfMessagesPublishedAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -9452,49 +14159,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeStorageSpaceAlarm.isOwnedResource(construct: IConstruct) +SnsNumberOfMessagesPublishedAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeStorageSpaceAlarm.isResource(construct: IConstruct) +SnsNumberOfMessagesPublishedAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeStorageSpaceAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SnsNumberOfMessagesPublishedAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -9502,7 +14209,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -9510,7 +14217,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -9518,17 +14225,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsInstanceFreeStorageSpaceAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceFreeStorageSpaceAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SnsNumberOfMessagesPublishedAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -9536,7 +14243,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -9544,7 +14251,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -9556,16 +14263,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -9577,7 +14284,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -9596,7 +14303,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -9608,7 +14315,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -9620,7 +14327,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -9632,7 +14339,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -9645,47 +14352,48 @@ The metric object this alarm was based on. --- -### RdsInstanceReadLatencyAlarm +### SnsNumberOfNotificationsDeliveredAlarm -An alarm that monitors the average amount of time taken per disk read I/O operation. +An alarm that monitors the number of notifications delivered by an SNS topic. -This alarm is used to detect high read latency. Database disks normally have a low read/write latency, -but they can have issues that can cause high latency operations. +This alarm helps you detect a drop in the volume of messages delivered. +You should create this alarm if you expect your system to have a +minimum traffic that it is serving. -The alarm is triggered when the average amount of time per disk read operation (in milliseconds) is -greater than threshold. +The alarm is triggered when the number of messages delivered by the topic +is less than the specified threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceReadLatencyAlarm(scope: Construct, id: string, props: RdsInstanceReadLatencyAlarmProps) +new SnsNumberOfNotificationsDeliveredAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsDeliveredAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceReadLatencyAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SnsNumberOfNotificationsDeliveredAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.Construct +- *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceReadLatencyAlarmProps +- *Type:* SnsNumberOfNotificationsDeliveredAlarmProps --- @@ -9693,17 +14401,17 @@ new RdsInstanceReadLatencyAlarm(scope: Construct, id: string, props: RdsInstance | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -9711,7 +14419,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -9727,13 +14435,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -9743,13 +14451,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -9759,13 +14467,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -9775,13 +14483,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -9789,7 +14497,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -9814,25 +14522,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceReadLatencyAlarm.isConstruct(x: any) +SnsNumberOfNotificationsDeliveredAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -9840,278 +14548,103 @@ Any object. --- -##### `isOwnedResource` - -```typescript -import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceReadLatencyAlarm.isOwnedResource(construct: IConstruct) -``` - -Returns true if the construct was created by CDK, and false otherwise. - -###### `construct`Required - -- *Type:* constructs.IConstruct - ---- - -##### `isResource` - -```typescript -import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceReadLatencyAlarm.isResource(construct: IConstruct) -``` - -Check whether the given construct is a Resource. - -###### `construct`Required - -- *Type:* constructs.IConstruct - ---- - -##### `fromAlarmArn` - -```typescript -import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceReadLatencyAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) -``` - -Import an existing CloudWatch alarm provided an ARN. - -###### `scope`Required - -- *Type:* constructs.Construct - -The parent creating construct (usually `this`). - ---- - -###### `id`Required - -- *Type:* string - -The construct's name. - ---- - -###### `alarmArn`Required - -- *Type:* string - -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). - ---- - -##### `fromAlarmName` - -```typescript -import { RdsInstanceReadLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -RdsInstanceReadLatencyAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) -``` - -Import an existing CloudWatch alarm provided an Name. - -###### `scope`Required - -- *Type:* constructs.Construct - -The parent creating construct (usually `this`). - ---- - -###### `id`Required - -- *Type:* string - -The construct's name. - ---- - -###### `alarmName`Required - -- *Type:* string - -Alarm Name. - ---- - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | - ---- - -##### `node`Required - -```typescript -public readonly node: Node; -``` - -- *Type:* constructs.Node - -The tree node. - ---- - -##### `env`Required - -```typescript -public readonly env: ResourceEnvironment; -``` - -- *Type:* aws-cdk-lib.ResourceEnvironment - -The environment this resource belongs to. - -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. - ---- - -##### `stack`Required +##### `isOwnedResource` ```typescript -public readonly stack: Stack; -``` - -- *Type:* aws-cdk-lib.Stack - -The stack in which this resource is defined. - ---- - -##### `alarmArn`Required +import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -```typescript -public readonly alarmArn: string; +SnsNumberOfNotificationsDeliveredAlarm.isOwnedResource(construct: IConstruct) ``` -- *Type:* string - -ARN of this alarm. - ---- - -##### `alarmName`Required - -```typescript -public readonly alarmName: string; -``` +Returns true if the construct was created by CDK, and false otherwise. -- *Type:* string +###### `construct`Required -Name of this alarm. +- *Type:* constructs.IConstruct --- -##### `metric`Required +##### `isResource` ```typescript -public readonly metric: IMetric; -``` - -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric - -The metric object this alarm was based on. +import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' ---- +SnsNumberOfNotificationsDeliveredAlarm.isResource(construct: IConstruct) +``` +Check whether the given construct is a Resource. -### RdsInstanceRecommendedAlarms +###### `construct`Required -A construct that creates recommended alarms for an RDS cluster instance. +- *Type:* constructs.IConstruct -> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#RDS) +--- -#### Initializers +##### `fromAlarmArn` ```typescript -import { RdsInstanceRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceRecommendedAlarms(scope: Construct, id: string, props: RdsInstanceRecommendedAlarmsProps) +SnsNumberOfNotificationsDeliveredAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceRecommendedAlarmsProps | *No description.* | - ---- +Import an existing CloudWatch alarm provided an ARN. -##### `scope`Required +###### `scope`Required - *Type:* constructs.Construct +The parent creating construct (usually `this`). + --- -##### `id`Required +###### `id`Required - *Type:* string ---- - -##### `props`Required - -- *Type:* RdsInstanceRecommendedAlarmsProps +The construct's name. --- -#### Methods +###### `alarmArn`Required -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | +- *Type:* string + +Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `toString` +##### `fromAlarmName` ```typescript -public toString(): string +import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +SnsNumberOfNotificationsDeliveredAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` -Returns a string representation of this construct. +Import an existing CloudWatch alarm provided an Name. -#### Static Functions +###### `scope`Required -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | +- *Type:* constructs.Construct + +The parent creating construct (usually `this`). --- -##### ~~`isConstruct`~~ +###### `id`Required -```typescript -import { RdsInstanceRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' +- *Type:* string -RdsInstanceRecommendedAlarms.isConstruct(x: any) -``` +The construct's name. -Checks if `x` is a construct. +--- -###### `x`Required +###### `alarmName`Required -- *Type:* any +- *Type:* string -Any object. +Alarm Name. --- @@ -10119,19 +14652,16 @@ Any object. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| alarmCpuUtilization | RdsInstanceCpuUtilizationAlarm | The CpuUtilization alarm for the database instance. | -| alarmDatabaseConnections | RdsInstanceDatabaseConnectionsAlarm | The DatabaseConnections alarm for the database instance. | -| alarmDbLoad | RdsInstanceDbLoadAlarm | The DbLoad alarm for the database instance. | -| alarmFreeableMemory | RdsInstanceFreeableMemoryAlarm | The FreeableMemory alarm for the database instance. | -| alarmFreeLocalStorage | RdsInstanceFreeLocalStorageAlarm | The FreeLocalStorage alarm for the database instance. | -| alarmFreeStorageSpace | RdsInstanceFreeStorageSpaceAlarm | The FreeStorageSpace alarm for the database instance. | -| alarmReadLatency | RdsInstanceReadLatencyAlarm | The ReadLatency alarm for the database instance. | -| alarmWriteLatency | RdsInstanceWriteLatencyAlarm | The WriteLatency alarm for the database instance. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -10143,144 +14673,115 @@ The tree node. --- -##### `alarmCpuUtilization`Optional - -```typescript -public readonly alarmCpuUtilization: RdsInstanceCpuUtilizationAlarm; -``` - -- *Type:* RdsInstanceCpuUtilizationAlarm - -The CpuUtilization alarm for the database instance. - ---- - -##### `alarmDatabaseConnections`Optional - -```typescript -public readonly alarmDatabaseConnections: RdsInstanceDatabaseConnectionsAlarm; -``` - -- *Type:* RdsInstanceDatabaseConnectionsAlarm - -The DatabaseConnections alarm for the database instance. - ---- - -##### `alarmDbLoad`Optional +##### `env`Required ```typescript -public readonly alarmDbLoad: RdsInstanceDbLoadAlarm; +public readonly env: ResourceEnvironment; ``` -- *Type:* RdsInstanceDbLoadAlarm - -The DbLoad alarm for the database instance. - ---- - -##### `alarmFreeableMemory`Optional - -```typescript -public readonly alarmFreeableMemory: RdsInstanceFreeableMemoryAlarm; -``` +- *Type:* aws-cdk-lib.ResourceEnvironment -- *Type:* RdsInstanceFreeableMemoryAlarm +The environment this resource belongs to. -The FreeableMemory alarm for the database instance. +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. --- -##### `alarmFreeLocalStorage`Optional +##### `stack`Required ```typescript -public readonly alarmFreeLocalStorage: RdsInstanceFreeLocalStorageAlarm; +public readonly stack: Stack; ``` -- *Type:* RdsInstanceFreeLocalStorageAlarm +- *Type:* aws-cdk-lib.Stack -The FreeLocalStorage alarm for the database instance. +The stack in which this resource is defined. --- -##### `alarmFreeStorageSpace`Optional +##### `alarmArn`Required ```typescript -public readonly alarmFreeStorageSpace: RdsInstanceFreeStorageSpaceAlarm; +public readonly alarmArn: string; ``` -- *Type:* RdsInstanceFreeStorageSpaceAlarm +- *Type:* string -The FreeStorageSpace alarm for the database instance. +ARN of this alarm. --- -##### `alarmReadLatency`Optional +##### `alarmName`Required ```typescript -public readonly alarmReadLatency: RdsInstanceReadLatencyAlarm; +public readonly alarmName: string; ``` -- *Type:* RdsInstanceReadLatencyAlarm +- *Type:* string -The ReadLatency alarm for the database instance. +Name of this alarm. --- -##### `alarmWriteLatency`Optional +##### `metric`Required ```typescript -public readonly alarmWriteLatency: RdsInstanceWriteLatencyAlarm; +public readonly metric: IMetric; ``` -- *Type:* RdsInstanceWriteLatencyAlarm +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -The WriteLatency alarm for the database instance. +The metric object this alarm was based on. --- -### RdsInstanceWriteLatencyAlarm +### SnsNumberOfNotificationsFailedAlarm -An alarm that monitors the average amount of time taken per disk write I/O operation. +An alarm that monitors the number of notifications failed by an SNS topic. -This alarm is used to detect high write latency. Database disks normally have a low read/write latency, -but they can have issues that can cause high latency operations. +This alarm helps you proactively find issues with the delivery of notifications +and take appropriate actions to address them. -The alarm is triggered when the average amount of time per disk write operation (in milliseconds) is -greater than threshold. +The alarm is triggered when the number of messages failed by the topic +is greater than the specified threshold. -#### Initializers +#### Initializers ```typescript -import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new RdsInstanceWriteLatencyAlarm(scope: Construct, id: string, props: RdsInstanceWriteLatencyAlarmProps) +new SnsNumberOfNotificationsFailedAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFailedAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | RdsInstanceWriteLatencyAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SnsNumberOfNotificationsFailedAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.Construct +- *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* RdsInstanceWriteLatencyAlarmProps +- *Type:* SnsNumberOfNotificationsFailedAlarmProps --- @@ -10288,17 +14789,17 @@ new RdsInstanceWriteLatencyAlarm(scope: Construct, id: string, props: RdsInstanc | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -10306,7 +14807,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -10322,13 +14823,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -10338,13 +14839,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -10354,13 +14855,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -10370,13 +14871,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -10384,7 +14885,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -10409,25 +14910,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceWriteLatencyAlarm.isConstruct(x: any) +SnsNumberOfNotificationsFailedAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -10435,49 +14936,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceWriteLatencyAlarm.isOwnedResource(construct: IConstruct) +SnsNumberOfNotificationsFailedAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceWriteLatencyAlarm.isResource(construct: IConstruct) +SnsNumberOfNotificationsFailedAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceWriteLatencyAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SnsNumberOfNotificationsFailedAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -10485,7 +14986,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -10493,7 +14994,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -10501,17 +15002,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { RdsInstanceWriteLatencyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -RdsInstanceWriteLatencyAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SnsNumberOfNotificationsFailedAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -10519,7 +15020,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -10527,7 +15028,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -10539,16 +15040,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -10560,7 +15061,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -10579,7 +15080,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -10591,7 +15092,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -10603,7 +15104,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -10615,7 +15116,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -10628,47 +15129,47 @@ The metric object this alarm was based on. --- -### S3Bucket4xxErrorsAlarm +### SnsNumberOfNotificationsFailedToRedriveToDlqAlarm -An alarm that monitors the 4xx errors for an S3 bucket. +An alarm that monitors the number of notifications failed to redrive to the dead-letter queue. -This alarm is used to create a baseline for typical 4xx error -rates so that you can look into any abnormalities that might -indicate a setup issue. +The alarm is used to detect messages that couldn't be moved to a dead-letter +queue. -The alarm is triggered when the 4xx error rate exceeds the % threshold. +The alarm is triggered when the number of messages failed to redrive to the +dead-letter queue is greater than the specified threshold. -#### Initializers +#### Initializers ```typescript -import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new S3Bucket4xxErrorsAlarm(scope: IConstruct, id: string, props: S3Bucket4xxErrorsAlarmProps) +new SnsNumberOfNotificationsFailedToRedriveToDlqAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFailedToRedriveToDlqAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | S3Bucket4xxErrorsAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SnsNumberOfNotificationsFailedToRedriveToDlqAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* S3Bucket4xxErrorsAlarmProps +- *Type:* SnsNumberOfNotificationsFailedToRedriveToDlqAlarmProps --- @@ -10676,17 +15177,17 @@ new S3Bucket4xxErrorsAlarm(scope: IConstruct, id: string, props: S3Bucket4xxErro | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -10694,7 +15195,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -10710,13 +15211,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -10726,13 +15227,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -10742,13 +15243,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -10758,13 +15259,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -10772,7 +15273,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -10797,25 +15298,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket4xxErrorsAlarm.isConstruct(x: any) +SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -10823,49 +15324,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket4xxErrorsAlarm.isOwnedResource(construct: IConstruct) +SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket4xxErrorsAlarm.isResource(construct: IConstruct) +SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket4xxErrorsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -10873,7 +15374,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -10881,7 +15382,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -10889,17 +15390,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { S3Bucket4xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket4xxErrorsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -10907,7 +15408,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -10915,7 +15416,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -10927,16 +15428,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -10948,7 +15449,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -10967,7 +15468,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -10979,7 +15480,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -10991,7 +15492,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -11003,7 +15504,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -11016,46 +15517,47 @@ The metric object this alarm was based on. --- -### S3Bucket5xxErrorsAlarm +### SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm -An alarm that monitors the 5xx errors for an S3 bucket. +An alarm that monitors the number of notifications filtered out due to invalid attributes. -This alarm can help to detect if the application is -experiencing issues due to 5xx errors. +The alarm is used to detect if the published messages are not valid or +if inappropriate filters have been applied to a subscriber. -The alarm is triggered when the 5xx error rate exceeds the % threshold. +The alarm is triggered when the number of messages filtered out due to +invalid attributes is greater than the specified threshold. -#### Initializers +#### Initializers ```typescript -import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new S3Bucket5xxErrorsAlarm(scope: IConstruct, id: string, props: S3Bucket5xxErrorsAlarmProps) +new SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmProps) ``` -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | S3Bucket5xxErrorsAlarmProps | *No description.* | +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* S3Bucket5xxErrorsAlarmProps +- *Type:* SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmProps --- @@ -11063,17 +15565,17 @@ new S3Bucket5xxErrorsAlarm(scope: IConstruct, id: string, props: S3Bucket5xxErro | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -11081,7 +15583,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -11097,13 +15599,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -11113,13 +15615,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -11129,13 +15631,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -11145,13 +15647,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -11159,7 +15661,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -11184,25 +15686,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket5xxErrorsAlarm.isConstruct(x: any) +SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -11210,49 +15712,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket5xxErrorsAlarm.isOwnedResource(construct: IConstruct) +SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket5xxErrorsAlarm.isResource(construct: IConstruct) +SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket5xxErrorsAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -11260,7 +15762,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -11268,7 +15770,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -11276,17 +15778,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { S3Bucket5xxErrorsAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -S3Bucket5xxErrorsAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -11294,7 +15796,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -11302,7 +15804,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -11314,16 +15816,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -11335,7 +15837,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -11354,7 +15856,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -11366,217 +15868,84 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; ``` -- *Type:* string - -ARN of this alarm. - ---- - -##### `alarmName`Required - -```typescript -public readonly alarmName: string; -``` - -- *Type:* string - -Name of this alarm. - ---- - -##### `metric`Required - -```typescript -public readonly metric: IMetric; -``` - -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric - -The metric object this alarm was based on. - ---- - - -### S3RecommendedAlarms - -A construct that creates the recommended alarms for an S3 bucket. - -> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#S3](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#S3) - -#### Initializers - -```typescript -import { S3RecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -new S3RecommendedAlarms(scope: Construct, id: string, props: S3RecommendedAlarmsProps) -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | S3RecommendedAlarmsProps | *No description.* | - ---- - -##### `scope`Required - -- *Type:* constructs.Construct - ---- - -##### `id`Required - -- *Type:* string - ---- - -##### `props`Required - -- *Type:* S3RecommendedAlarmsProps - ---- - -#### Methods - -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | - ---- - -##### `toString` - -```typescript -public toString(): string -``` - -Returns a string representation of this construct. - -#### Static Functions - -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | - ---- - -##### ~~`isConstruct`~~ - -```typescript -import { S3RecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -S3RecommendedAlarms.isConstruct(x: any) -``` - -Checks if `x` is a construct. - -###### `x`Required - -- *Type:* any - -Any object. - ---- - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| alarm4xxErrors | S3Bucket4xxErrorsAlarm | The 4xx errors alarm. | -| alarm5xxErrors | S3Bucket5xxErrorsAlarm | The 5xx errors alarm. | - ---- - -##### `node`Required - -```typescript -public readonly node: Node; -``` - -- *Type:* constructs.Node +- *Type:* string -The tree node. +ARN of this alarm. --- -##### `alarm4xxErrors`Optional +##### `alarmName`Required ```typescript -public readonly alarm4xxErrors: S3Bucket4xxErrorsAlarm; +public readonly alarmName: string; ``` -- *Type:* S3Bucket4xxErrorsAlarm +- *Type:* string -The 4xx errors alarm. +Name of this alarm. --- -##### `alarm5xxErrors`Optional +##### `metric`Required ```typescript -public readonly alarm5xxErrors: S3Bucket5xxErrorsAlarm; +public readonly metric: IMetric; ``` -- *Type:* S3Bucket5xxErrorsAlarm +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -The 5xx errors alarm. +The metric object this alarm was based on. --- -### SnsNumberOfMessagesPublishedAlarm +### SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm -An alarm that monitors the number of messages published to an SNS topic. +An alarm that monitors the number of notifications filtered out due to invalid message body. -This alarm helps you proactively monitor and detect significant drops in -notification publishing. This helps you identify potential issues with -your application or business processes, so that you can take appropriate -actions to maintain the expected flow of notifications. You should create -this alarm if you expect your system to have a minimum traffic that it -is serving. +The alarm is used to detect if the published messages are not valid or +if inappropriate filters have been applied to a subscriber. -The alarm is triggered when the number of messages published to the topic -is less than the specified threshold. +The alarm is triggered when the number of messages filtered out due to +invalid message body is greater than the specified threshold. -#### Initializers +#### Initializers ```typescript -import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SnsNumberOfMessagesPublishedAlarm(scope: IConstruct, id: string, props: SnsNumberOfMessagesPublishedAlarmProps) +new SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SnsNumberOfMessagesPublishedAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* SnsNumberOfMessagesPublishedAlarmProps +- *Type:* SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmProps --- @@ -11584,17 +15953,17 @@ new SnsNumberOfMessagesPublishedAlarm(scope: IConstruct, id: string, props: SnsN | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -11602,7 +15971,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -11618,13 +15987,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -11634,13 +16003,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -11650,13 +16019,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -11666,13 +16035,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -11680,7 +16049,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -11705,25 +16074,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfMessagesPublishedAlarm.isConstruct(x: any) +SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -11731,49 +16100,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfMessagesPublishedAlarm.isOwnedResource(construct: IConstruct) +SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfMessagesPublishedAlarm.isResource(construct: IConstruct) +SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfMessagesPublishedAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -11781,7 +16150,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -11789,7 +16158,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -11797,17 +16166,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { SnsNumberOfMessagesPublishedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfMessagesPublishedAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -11815,7 +16184,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -11823,7 +16192,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -11835,16 +16204,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -11856,7 +16225,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -11875,7 +16244,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -11887,7 +16256,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -11899,7 +16268,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -11911,7 +16280,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -11924,48 +16293,48 @@ The metric object this alarm was based on. --- -### SnsNumberOfNotificationsDeliveredAlarm +### SnsNumberOfNotificationsRedrivenToDlqAlarm -An alarm that monitors the number of notifications delivered by an SNS topic. +An alarm that monitors the number of notifications redriven to the dead-letter queue. -This alarm helps you detect a drop in the volume of messages delivered. -You should create this alarm if you expect your system to have a -minimum traffic that it is serving. +The alarm is used to detect messages that moved to a dead-letter +queue. We recommend that you create this alarm when SNS is coupled +with SQS, Lambda or Firehose. -The alarm is triggered when the number of messages delivered by the topic -is less than the specified threshold. +The alarm is triggered when the number of messages redriven to the +dead-letter queue is greater than the specified threshold. -#### Initializers +#### Initializers ```typescript -import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SnsNumberOfNotificationsDeliveredAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsDeliveredAlarmProps) +new SnsNumberOfNotificationsRedrivenToDlqAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsRedrivenToDlqAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SnsNumberOfNotificationsDeliveredAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SnsNumberOfNotificationsRedrivenToDlqAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* SnsNumberOfNotificationsDeliveredAlarmProps +- *Type:* SnsNumberOfNotificationsRedrivenToDlqAlarmProps --- @@ -11973,17 +16342,17 @@ new SnsNumberOfNotificationsDeliveredAlarm(scope: IConstruct, id: string, props: | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -11991,7 +16360,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -12007,13 +16376,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -12023,13 +16392,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -12039,13 +16408,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -12055,13 +16424,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -12069,7 +16438,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -12094,25 +16463,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsDeliveredAlarm.isConstruct(x: any) +SnsNumberOfNotificationsRedrivenToDlqAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -12120,49 +16489,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsDeliveredAlarm.isOwnedResource(construct: IConstruct) +SnsNumberOfNotificationsRedrivenToDlqAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsDeliveredAlarm.isResource(construct: IConstruct) +SnsNumberOfNotificationsRedrivenToDlqAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsDeliveredAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SnsNumberOfNotificationsRedrivenToDlqAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -12170,7 +16539,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -12178,7 +16547,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -12186,17 +16555,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { SnsNumberOfNotificationsDeliveredAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsDeliveredAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SnsNumberOfNotificationsRedrivenToDlqAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -12204,7 +16573,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -12212,7 +16581,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -12224,16 +16593,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -12245,7 +16614,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -12260,351 +16629,138 @@ For resources that are created and managed by the CDK this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. - ---- - -##### `stack`Required - -```typescript -public readonly stack: Stack; -``` - -- *Type:* aws-cdk-lib.Stack - -The stack in which this resource is defined. - ---- - -##### `alarmArn`Required - -```typescript -public readonly alarmArn: string; -``` - -- *Type:* string - -ARN of this alarm. - ---- - -##### `alarmName`Required - -```typescript -public readonly alarmName: string; -``` - -- *Type:* string - -Name of this alarm. - ---- - -##### `metric`Required - -```typescript -public readonly metric: IMetric; -``` - -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric - -The metric object this alarm was based on. - ---- - - -### SnsNumberOfNotificationsFailedAlarm - -An alarm that monitors the number of notifications failed by an SNS topic. - -This alarm helps you proactively find issues with the delivery of notifications -and take appropriate actions to address them. - -The alarm is triggered when the number of messages failed by the topic -is greater than the specified threshold. - -#### Initializers - -```typescript -import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -new SnsNumberOfNotificationsFailedAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFailedAlarmProps) -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SnsNumberOfNotificationsFailedAlarmProps | *No description.* | - ---- - -##### `scope`Required - -- *Type:* constructs.IConstruct - ---- - -##### `id`Required - -- *Type:* string - ---- - -##### `props`Required - -- *Type:* SnsNumberOfNotificationsFailedAlarmProps - ---- - -#### Methods - -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | - ---- - -##### `toString` - -```typescript -public toString(): string -``` - -Returns a string representation of this construct. - -##### `applyRemovalPolicy` - -```typescript -public applyRemovalPolicy(policy: RemovalPolicy): void -``` - -Apply the given removal policy to this resource. - -The Removal Policy controls what happens to this resource when it stops -being managed by CloudFormation, either because you've removed it from the -CDK application or because you've made a change that requires the resource -to be replaced. - -The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS -account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). - -###### `policy`Required - -- *Type:* aws-cdk-lib.RemovalPolicy - ---- - -##### `addAlarmAction` - -```typescript -public addAlarmAction(actions: IAlarmAction): void -``` - -Trigger this action if the alarm fires. - -Typically SnsAction or AutoScalingAction. - -###### `actions`Required - -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction - ---- - -##### `addInsufficientDataAction` - -```typescript -public addInsufficientDataAction(actions: IAlarmAction): void -``` - -Trigger this action if there is insufficient data to evaluate the alarm. - -Typically SnsAction or AutoScalingAction. - -###### `actions`Required - -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction - ---- - -##### `addOkAction` - -```typescript -public addOkAction(actions: IAlarmAction): void -``` - -Trigger this action if the alarm returns from breaching state into ok state. - -Typically SnsAction or AutoScalingAction. - -###### `actions`Required - -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction - ---- - -##### `renderAlarmRule` - -```typescript -public renderAlarmRule(): string -``` +that might be different than the stack they were imported into. -AlarmRule indicating ALARM state for Alarm. +--- -##### `toAnnotation` +##### `stack`Required ```typescript -public toAnnotation(): HorizontalAnnotation +public readonly stack: Stack; ``` -Turn this alarm into a horizontal annotation. +- *Type:* aws-cdk-lib.Stack -This is useful if you want to represent an Alarm in a non-AlarmWidget. -An `AlarmWidget` can directly show an alarm, but it can only show a -single alarm and no other metrics. Instead, you can convert the alarm to -a HorizontalAnnotation and add it as an annotation to another graph. +The stack in which this resource is defined. -This might be useful if: +--- -- You want to show multiple alarms inside a single graph, for example if - you have both a "small margin/long period" alarm as well as a - "large margin/short period" alarm. +##### `alarmArn`Required -- You want to show an Alarm line in a graph with multiple metrics in it. +```typescript +public readonly alarmArn: string; +``` -#### Static Functions +- *Type:* string -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +ARN of this alarm. --- -##### ~~`isConstruct`~~ +##### `alarmName`Required ```typescript -import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SnsNumberOfNotificationsFailedAlarm.isConstruct(x: any) +public readonly alarmName: string; ``` -Checks if `x` is a construct. - -###### `x`Required - -- *Type:* any +- *Type:* string -Any object. +Name of this alarm. --- -##### `isOwnedResource` +##### `metric`Required ```typescript -import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SnsNumberOfNotificationsFailedAlarm.isOwnedResource(construct: IConstruct) +public readonly metric: IMetric; ``` -Returns true if the construct was created by CDK, and false otherwise. - -###### `construct`Required +- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric -- *Type:* constructs.IConstruct +The metric object this alarm was based on. --- -##### `isResource` - -```typescript -import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SnsNumberOfNotificationsFailedAlarm.isResource(construct: IConstruct) -``` - -Check whether the given construct is a Resource. -###### `construct`Required +### SnsRecommendedAlarms -- *Type:* constructs.IConstruct +A construct that creates recommended alarms for an SNS topic. ---- +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS) -##### `fromAlarmArn` +#### Initializers ```typescript -import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SnsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFailedAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +new SnsRecommendedAlarms(scope: Construct, id: string, props: SnsRecommendedAlarmsProps) ``` -Import an existing CloudWatch alarm provided an ARN. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | SnsRecommendedAlarmsProps | *No description.* | -###### `scope`Required +--- -- *Type:* constructs.Construct +##### `scope`Required -The parent creating construct (usually `this`). +- *Type:* constructs.Construct --- -###### `id`Required +##### `id`Required - *Type:* string -The construct's name. - --- -###### `alarmArn`Required +##### `props`Required -- *Type:* string +- *Type:* SnsRecommendedAlarmsProps -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | --- -##### `fromAlarmName` +##### `toString` ```typescript -import { SnsNumberOfNotificationsFailedAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SnsNumberOfNotificationsFailedAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +public toString(): string ``` -Import an existing CloudWatch alarm provided an Name. - -###### `scope`Required +Returns a string representation of this construct. -- *Type:* constructs.Construct +#### Static Functions -The parent creating construct (usually `this`). +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | --- -###### `id`Required +##### ~~`isConstruct`~~ -- *Type:* string +```typescript +import { SnsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' -The construct's name. +SnsRecommendedAlarms.isConstruct(x: any) +``` ---- +Checks if `x` is a construct. -###### `alarmName`Required +###### `x`Required -- *Type:* string +- *Type:* any -Alarm Name. +Any object. --- @@ -12612,16 +16768,18 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| alarmNumberOfMessagesPublished | SnsNumberOfMessagesPublishedAlarm | The NumberOfMessagesPublished alarm. | +| alarmNumberOfNotificationsDelivered | SnsNumberOfNotificationsDeliveredAlarm | The NumberOfNotificationsDelivered alarm. | +| alarmNumberOfNotificationsFailed | SnsNumberOfNotificationsFailedAlarm | The NumberOfNotificationsFailed alarm. | +| alarmNumberOfNotificationsFailedToRedriveToDlq | SnsNumberOfNotificationsFailedToRedriveToDlqAlarm | The NumberOfNotificationsFailedToRedriveToDlq alarm. | +| alarmNumberOfNotificationsFilteredOutInvalidAttributes | SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm | The NumberOfNotificationsFilteredOutInvalidAttributes alarm. | +| alarmNumberOfNotificationsFilteredOutInvalidMessageBody | SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm | The NumberOfNotificationsFilteredOutInvalidMessageBody alarm. | +| alarmNumberOfNotificationsRedrivenToDlq | SnsNumberOfNotificationsRedrivenToDlqAlarm | The NumberOfNotificationsRedrivenToDlq alarm. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -12633,115 +16791,135 @@ The tree node. --- -##### `env`Required +##### `alarmNumberOfMessagesPublished`Optional ```typescript -public readonly env: ResourceEnvironment; +public readonly alarmNumberOfMessagesPublished: SnsNumberOfMessagesPublishedAlarm; ``` -- *Type:* aws-cdk-lib.ResourceEnvironment +- *Type:* SnsNumberOfMessagesPublishedAlarm -The environment this resource belongs to. +The NumberOfMessagesPublished alarm. -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +--- + +##### `alarmNumberOfNotificationsDelivered`Optional + +```typescript +public readonly alarmNumberOfNotificationsDelivered: SnsNumberOfNotificationsDeliveredAlarm; +``` + +- *Type:* SnsNumberOfNotificationsDeliveredAlarm + +The NumberOfNotificationsDelivered alarm. --- -##### `stack`Required +##### `alarmNumberOfNotificationsFailed`Optional ```typescript -public readonly stack: Stack; +public readonly alarmNumberOfNotificationsFailed: SnsNumberOfNotificationsFailedAlarm; ``` -- *Type:* aws-cdk-lib.Stack +- *Type:* SnsNumberOfNotificationsFailedAlarm -The stack in which this resource is defined. +The NumberOfNotificationsFailed alarm. --- -##### `alarmArn`Required +##### `alarmNumberOfNotificationsFailedToRedriveToDlq`Optional ```typescript -public readonly alarmArn: string; +public readonly alarmNumberOfNotificationsFailedToRedriveToDlq: SnsNumberOfNotificationsFailedToRedriveToDlqAlarm; ``` -- *Type:* string +- *Type:* SnsNumberOfNotificationsFailedToRedriveToDlqAlarm -ARN of this alarm. +The NumberOfNotificationsFailedToRedriveToDlq alarm. --- -##### `alarmName`Required +##### `alarmNumberOfNotificationsFilteredOutInvalidAttributes`Optional ```typescript -public readonly alarmName: string; +public readonly alarmNumberOfNotificationsFilteredOutInvalidAttributes: SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm; ``` -- *Type:* string +- *Type:* SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm -Name of this alarm. +The NumberOfNotificationsFilteredOutInvalidAttributes alarm. --- -##### `metric`Required +##### `alarmNumberOfNotificationsFilteredOutInvalidMessageBody`Optional ```typescript -public readonly metric: IMetric; +public readonly alarmNumberOfNotificationsFilteredOutInvalidMessageBody: SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm; ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +- *Type:* SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm -The metric object this alarm was based on. +The NumberOfNotificationsFilteredOutInvalidMessageBody alarm. --- +##### `alarmNumberOfNotificationsRedrivenToDlq`Optional -### SnsNumberOfNotificationsFailedToRedriveToDlqAlarm +```typescript +public readonly alarmNumberOfNotificationsRedrivenToDlq: SnsNumberOfNotificationsRedrivenToDlqAlarm; +``` -An alarm that monitors the number of notifications failed to redrive to the dead-letter queue. +- *Type:* SnsNumberOfNotificationsRedrivenToDlqAlarm -The alarm is used to detect messages that couldn't be moved to a dead-letter -queue. +The NumberOfNotificationsRedrivenToDlq alarm. -The alarm is triggered when the number of messages failed to redrive to the -dead-letter queue is greater than the specified threshold. +--- -#### Initializers + +### SqsApproximateAgeOfOldestMessageAlarm + +An alarm that watches the age of the oldest message in the queue. + +This alarm is used to detect whether the age of the oldest message +in the QueueName queue is too high. High age can be an indication +that messages are not processed quickly enough or that there are +some poison-pill messages that are stuck in the queue and can't +be processed. + +This alarm is triggered when the age of the oldest message in the +queue exceeds or is equal to the specified threshold. + +#### Initializers ```typescript -import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SnsNumberOfNotificationsFailedToRedriveToDlqAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFailedToRedriveToDlqAlarmProps) +new SqsApproximateAgeOfOldestMessageAlarm(scope: IConstruct, id: string, props: SqsApproximateAgeOfOldestMessageAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SnsNumberOfNotificationsFailedToRedriveToDlqAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SqsApproximateAgeOfOldestMessageAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* SnsNumberOfNotificationsFailedToRedriveToDlqAlarmProps +- *Type:* SqsApproximateAgeOfOldestMessageAlarmProps --- @@ -12749,17 +16927,17 @@ new SnsNumberOfNotificationsFailedToRedriveToDlqAlarm(scope: IConstruct, id: str | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -12767,7 +16945,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -12783,13 +16961,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -12799,13 +16977,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -12815,13 +16993,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -12831,13 +17009,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -12845,7 +17023,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -12870,25 +17048,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.isConstruct(x: any) +SqsApproximateAgeOfOldestMessageAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -12896,49 +17074,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.isOwnedResource(construct: IConstruct) +SqsApproximateAgeOfOldestMessageAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.isResource(construct: IConstruct) +SqsApproximateAgeOfOldestMessageAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SqsApproximateAgeOfOldestMessageAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -12946,7 +17124,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -12954,7 +17132,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -12962,17 +17140,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { SnsNumberOfNotificationsFailedToRedriveToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFailedToRedriveToDlqAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SqsApproximateAgeOfOldestMessageAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -12980,7 +17158,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -12988,7 +17166,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -13000,16 +17178,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -13021,7 +17199,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -13040,7 +17218,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -13052,7 +17230,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -13064,7 +17242,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -13076,7 +17254,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -13089,47 +17267,56 @@ The metric object this alarm was based on. --- -### SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm +### SqsApproximateNumberOfMessagesNotVisibleAlarm -An alarm that monitors the number of notifications filtered out due to invalid attributes. +An alarm that watches the number of messages that are in flight. -The alarm is used to detect if the published messages are not valid or -if inappropriate filters have been applied to a subscriber. +This alarm is used to detect a high number of in-flight messages +in the queue. If consumers do not delete messages within the +visibility timeout period, when the queue is polled, messages +reappear in the queue. For FIFO queues, there can be a maximum +of 20,000 in-flight messages. If you reach this quota, SQS returns +no error messages. A FIFO queue looks through the first 20k +messages to determine available message groups. This means that +if you have a backlog of messages in a single message group, +you cannot consume messages from other message groups that were +sent to the queue at a later time until you successfully +consume the messages from the backlog. -The alarm is triggered when the number of messages filtered out due to -invalid attributes is greater than the specified threshold. +This alarm is triggered when the number of messages that are in +flight exceeds or is equal to the specified threshold. -#### Initializers +#### Initializers ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmProps) +new SqsApproximateNumberOfMessagesNotVisibleAlarm(scope: IConstruct, id: string, props: SqsApproximateNumberOfMessagesNotVisibleAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SqsApproximateNumberOfMessagesNotVisibleAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmProps +- *Type:* SqsApproximateNumberOfMessagesNotVisibleAlarmProps --- @@ -13137,17 +17324,17 @@ new SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm(scope: IConstruct, | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -13155,7 +17342,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -13171,13 +17358,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -13187,13 +17374,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -13203,13 +17390,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -13219,13 +17406,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -13233,7 +17420,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -13258,25 +17445,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.isConstruct(x: any) +SqsApproximateNumberOfMessagesNotVisibleAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -13284,49 +17471,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.isOwnedResource(construct: IConstruct) +SqsApproximateNumberOfMessagesNotVisibleAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.isResource(construct: IConstruct) +SqsApproximateNumberOfMessagesNotVisibleAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SqsApproximateNumberOfMessagesNotVisibleAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -13334,7 +17521,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -13342,7 +17529,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -13350,17 +17537,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SqsApproximateNumberOfMessagesNotVisibleAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -13368,7 +17555,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -13376,7 +17563,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -13388,16 +17575,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -13409,7 +17596,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -13428,7 +17615,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -13440,7 +17627,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -13452,7 +17639,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -13464,7 +17651,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -13477,47 +17664,50 @@ The metric object this alarm was based on. --- -### SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm +### SqsApproximateNumberOfMessagesVisibleAlarm -An alarm that monitors the number of notifications filtered out due to invalid message body. +An alarm that watches the number of messages that are visible in the queue. -The alarm is used to detect if the published messages are not valid or -if inappropriate filters have been applied to a subscriber. +This alarm is used to detect whether the message +count of the active queue is too high and consumers +are slow to process the messages or there are not +enough consumers to process them. -The alarm is triggered when the number of messages filtered out due to -invalid message body is greater than the specified threshold. +This alarm is triggered when the number of messages +that are visible in the queue exceeds or is equal to +the specified threshold. -#### Initializers +#### Initializers ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmProps) +new SqsApproximateNumberOfMessagesVisibleAlarm(scope: IConstruct, id: string, props: SqsApproximateNumberOfMessagesVisibleAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SqsApproximateNumberOfMessagesVisibleAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmProps +- *Type:* SqsApproximateNumberOfMessagesVisibleAlarmProps --- @@ -13525,17 +17715,17 @@ new SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm(scope: IConstruct | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -13543,7 +17733,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -13559,13 +17749,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -13575,13 +17765,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -13591,13 +17781,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -13607,13 +17797,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -13621,7 +17811,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -13646,25 +17836,25 @@ This might be useful if: | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.isConstruct(x: any) +SqsApproximateNumberOfMessagesVisibleAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -13672,49 +17862,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.isOwnedResource(construct: IConstruct) +SqsApproximateNumberOfMessagesVisibleAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.isResource(construct: IConstruct) +SqsApproximateNumberOfMessagesVisibleAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SqsApproximateNumberOfMessagesVisibleAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -13722,7 +17912,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -13730,7 +17920,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -13738,17 +17928,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SqsApproximateNumberOfMessagesVisibleAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -13756,7 +17946,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -13764,7 +17954,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -13776,16 +17966,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -13797,7 +17987,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -13816,7 +18006,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -13828,7 +18018,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -13840,7 +18030,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -13852,7 +18042,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -13865,48 +18055,46 @@ The metric object this alarm was based on. --- -### SnsNumberOfNotificationsRedrivenToDlqAlarm +### SqsNumberOfMessagesSentAlarm -An alarm that monitors the number of notifications redriven to the dead-letter queue. +An alarm that watches the number of messages that are sent. -The alarm is used to detect messages that moved to a dead-letter -queue. We recommend that you create this alarm when SNS is coupled -with SQS, Lambda or Firehose. +This alarm is used to detect when a producer stops sending messages. -The alarm is triggered when the number of messages redriven to the -dead-letter queue is greater than the specified threshold. +This alarm is triggered when the number of messages sent is less than +or equal to the specified threshold. By default, 0. -#### Initializers +#### Initializers ```typescript -import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SnsNumberOfNotificationsRedrivenToDlqAlarm(scope: IConstruct, id: string, props: SnsNumberOfNotificationsRedrivenToDlqAlarmProps) +new SqsNumberOfMessagesSentAlarm(scope: IConstruct, id: string, props: SqsNumberOfMessagesSentAlarmProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SnsNumberOfNotificationsRedrivenToDlqAlarmProps | *No description.* | +| scope | constructs.IConstruct | *No description.* | +| id | string | *No description.* | +| props | SqsNumberOfMessagesSentAlarmProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.IConstruct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* SnsNumberOfNotificationsRedrivenToDlqAlarmProps +- *Type:* SqsNumberOfMessagesSentAlarmProps --- @@ -13914,17 +18102,17 @@ new SnsNumberOfNotificationsRedrivenToDlqAlarm(scope: IConstruct, id: string, pr | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addAlarmAction | Trigger this action if the alarm fires. | +| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | +| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | +| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | +| toAnnotation | Turn this alarm into a horizontal annotation. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -13932,7 +18120,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -13948,13 +18136,13 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addAlarmAction` ```typescript public addAlarmAction(actions: IAlarmAction): void @@ -13964,13 +18152,13 @@ Trigger this action if the alarm fires. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addInsufficientDataAction` +##### `addInsufficientDataAction` ```typescript public addInsufficientDataAction(actions: IAlarmAction): void @@ -13980,13 +18168,13 @@ Trigger this action if there is insufficient data to evaluate the alarm. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `addOkAction` +##### `addOkAction` ```typescript public addOkAction(actions: IAlarmAction): void @@ -13996,13 +18184,13 @@ Trigger this action if the alarm returns from breaching state into ok state. Typically SnsAction or AutoScalingAction. -###### `actions`Required +###### `actions`Required - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction --- -##### `renderAlarmRule` +##### `renderAlarmRule` ```typescript public renderAlarmRule(): string @@ -14010,7 +18198,7 @@ public renderAlarmRule(): string AlarmRule indicating ALARM state for Alarm. -##### `toAnnotation` +##### `toAnnotation` ```typescript public toAnnotation(): HorizontalAnnotation @@ -14031,29 +18219,29 @@ This might be useful if: - You want to show an Alarm line in a graph with multiple metrics in it. -#### Static Functions - -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | +| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsRedrivenToDlqAlarm.isConstruct(x: any) +SqsNumberOfMessagesSentAlarm.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -14061,49 +18249,49 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsRedrivenToDlqAlarm.isOwnedResource(construct: IConstruct) +SqsNumberOfMessagesSentAlarm.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsRedrivenToDlqAlarm.isResource(construct: IConstruct) +SqsNumberOfMessagesSentAlarm.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromAlarmArn` ```typescript -import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsRedrivenToDlqAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +SqsNumberOfMessagesSentAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) ``` Import an existing CloudWatch alarm provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -14111,7 +18299,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -14119,7 +18307,7 @@ The construct's name. --- -###### `alarmArn`Required +###### `alarmArn`Required - *Type:* string @@ -14127,17 +18315,17 @@ Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). --- -##### `fromAlarmName` +##### `fromAlarmName` ```typescript -import { SnsNumberOfNotificationsRedrivenToDlqAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsNumberOfNotificationsRedrivenToDlqAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +SqsNumberOfMessagesSentAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) ``` Import an existing CloudWatch alarm provided an Name. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct @@ -14145,7 +18333,7 @@ The parent creating construct (usually `this`). --- -###### `id`Required +###### `id`Required - *Type:* string @@ -14153,7 +18341,7 @@ The construct's name. --- -###### `alarmName`Required +###### `alarmName`Required - *Type:* string @@ -14165,16 +18353,16 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| alarmArn | string | ARN of this alarm. | +| alarmName | string | Name of this alarm. | +| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -14186,7 +18374,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -14205,7 +18393,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -14217,7 +18405,7 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `alarmArn`Required ```typescript public readonly alarmArn: string; @@ -14229,7 +18417,7 @@ ARN of this alarm. --- -##### `alarmName`Required +##### `alarmName`Required ```typescript public readonly alarmName: string; @@ -14241,7 +18429,7 @@ Name of this alarm. --- -##### `metric`Required +##### `metric`Required ```typescript public readonly metric: IMetric; @@ -14254,43 +18442,39 @@ The metric object this alarm was based on. --- -### SnsRecommendedAlarms - -A construct that creates recommended alarms for an SNS topic. - -> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS) +### SqsRecommendedAlarms -#### Initializers +#### Initializers ```typescript -import { SnsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SnsRecommendedAlarms(scope: Construct, id: string, props: SnsRecommendedAlarmsProps) +new SqsRecommendedAlarms(scope: Construct, id: string, props: SqsRecommendedAlarmsProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | SnsRecommendedAlarmsProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | SqsRecommendedAlarmsProps | *No description.* | --- -##### `scope`Required +##### `scope`Required - *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Required -- *Type:* SnsRecommendedAlarmsProps +- *Type:* SqsRecommendedAlarmsProps --- @@ -14298,11 +18482,11 @@ new SnsRecommendedAlarms(scope: Construct, id: string, props: SnsRecommendedAlar | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | +| toString | Returns a string representation of this construct. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -14314,21 +18498,21 @@ Returns a string representation of this construct. | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | +| isConstruct | Checks if `x` is a construct. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SnsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { SqsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SnsRecommendedAlarms.isConstruct(x: any) +SqsRecommendedAlarms.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -14340,18 +18524,15 @@ Any object. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| alarmNumberOfMessagesPublished | SnsNumberOfMessagesPublishedAlarm | The NumberOfMessagesPublished alarm. | -| alarmNumberOfNotificationsDelivered | SnsNumberOfNotificationsDeliveredAlarm | The NumberOfNotificationsDelivered alarm. | -| alarmNumberOfNotificationsFailed | SnsNumberOfNotificationsFailedAlarm | The NumberOfNotificationsFailed alarm. | -| alarmNumberOfNotificationsFailedToRedriveToDlq | SnsNumberOfNotificationsFailedToRedriveToDlqAlarm | The NumberOfNotificationsFailedToRedriveToDlq alarm. | -| alarmNumberOfNotificationsFilteredOutInvalidAttributes | SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm | The NumberOfNotificationsFilteredOutInvalidAttributes alarm. | -| alarmNumberOfNotificationsFilteredOutInvalidMessageBody | SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm | The NumberOfNotificationsFilteredOutInvalidMessageBody alarm. | -| alarmNumberOfNotificationsRedrivenToDlq | SnsNumberOfNotificationsRedrivenToDlqAlarm | The NumberOfNotificationsRedrivenToDlq alarm. | +| node | constructs.Node | The tree node. | +| alarmApproximateAgeOfOldestMessage | SqsApproximateAgeOfOldestMessageAlarm | The approximate age of oldest message alarm. | +| alarmApproximateNumberOfMessagesNotVisible | SqsApproximateNumberOfMessagesNotVisibleAlarm | The approximate number of messages not visible alarm. | +| alarmApproximateNumberOfMessagesVisible | SqsApproximateNumberOfMessagesVisibleAlarm | The approximate number of messages visible alarm. | +| alarmNumberOfMessagesSent | SqsNumberOfMessagesSentAlarm | The number of messages sent alarm. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -14363,135 +18544,90 @@ The tree node. --- -##### `alarmNumberOfMessagesPublished`Optional - -```typescript -public readonly alarmNumberOfMessagesPublished: SnsNumberOfMessagesPublishedAlarm; -``` - -- *Type:* SnsNumberOfMessagesPublishedAlarm - -The NumberOfMessagesPublished alarm. - ---- - -##### `alarmNumberOfNotificationsDelivered`Optional - -```typescript -public readonly alarmNumberOfNotificationsDelivered: SnsNumberOfNotificationsDeliveredAlarm; -``` - -- *Type:* SnsNumberOfNotificationsDeliveredAlarm - -The NumberOfNotificationsDelivered alarm. - ---- - -##### `alarmNumberOfNotificationsFailed`Optional - -```typescript -public readonly alarmNumberOfNotificationsFailed: SnsNumberOfNotificationsFailedAlarm; -``` - -- *Type:* SnsNumberOfNotificationsFailedAlarm - -The NumberOfNotificationsFailed alarm. - ---- - -##### `alarmNumberOfNotificationsFailedToRedriveToDlq`Optional +##### `alarmApproximateAgeOfOldestMessage`Optional ```typescript -public readonly alarmNumberOfNotificationsFailedToRedriveToDlq: SnsNumberOfNotificationsFailedToRedriveToDlqAlarm; +public readonly alarmApproximateAgeOfOldestMessage: SqsApproximateAgeOfOldestMessageAlarm; ``` -- *Type:* SnsNumberOfNotificationsFailedToRedriveToDlqAlarm +- *Type:* SqsApproximateAgeOfOldestMessageAlarm -The NumberOfNotificationsFailedToRedriveToDlq alarm. +The approximate age of oldest message alarm. --- -##### `alarmNumberOfNotificationsFilteredOutInvalidAttributes`Optional +##### `alarmApproximateNumberOfMessagesNotVisible`Optional ```typescript -public readonly alarmNumberOfNotificationsFilteredOutInvalidAttributes: SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm; +public readonly alarmApproximateNumberOfMessagesNotVisible: SqsApproximateNumberOfMessagesNotVisibleAlarm; ``` -- *Type:* SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm +- *Type:* SqsApproximateNumberOfMessagesNotVisibleAlarm -The NumberOfNotificationsFilteredOutInvalidAttributes alarm. +The approximate number of messages not visible alarm. --- -##### `alarmNumberOfNotificationsFilteredOutInvalidMessageBody`Optional +##### `alarmApproximateNumberOfMessagesVisible`Optional ```typescript -public readonly alarmNumberOfNotificationsFilteredOutInvalidMessageBody: SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm; +public readonly alarmApproximateNumberOfMessagesVisible: SqsApproximateNumberOfMessagesVisibleAlarm; ``` -- *Type:* SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm +- *Type:* SqsApproximateNumberOfMessagesVisibleAlarm -The NumberOfNotificationsFilteredOutInvalidMessageBody alarm. +The approximate number of messages visible alarm. --- -##### `alarmNumberOfNotificationsRedrivenToDlq`Optional +##### `alarmNumberOfMessagesSent`Optional ```typescript -public readonly alarmNumberOfNotificationsRedrivenToDlq: SnsNumberOfNotificationsRedrivenToDlqAlarm; +public readonly alarmNumberOfMessagesSent: SqsNumberOfMessagesSentAlarm; ``` -- *Type:* SnsNumberOfNotificationsRedrivenToDlqAlarm +- *Type:* SqsNumberOfMessagesSentAlarm -The NumberOfNotificationsRedrivenToDlq alarm. +The number of messages sent alarm. --- -### SqsApproximateAgeOfOldestMessageAlarm - -An alarm that watches the age of the oldest message in the queue. - -This alarm is used to detect whether the age of the oldest message -in the QueueName queue is too high. High age can be an indication -that messages are not processed quickly enough or that there are -some poison-pill messages that are stuck in the queue and can't -be processed. +### Topic -This alarm is triggered when the age of the oldest message in the -queue exceeds or is equal to the specified threshold. +An extension of the SNS topic construct that provides helper methods to create recommended alarms. -#### Initializers +#### Initializers ```typescript -import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SqsApproximateAgeOfOldestMessageAlarm(scope: IConstruct, id: string, props: SqsApproximateAgeOfOldestMessageAlarmProps) +new Topic(scope: Construct, id: string, props?: TopicProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SqsApproximateAgeOfOldestMessageAlarmProps | *No description.* | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | aws-cdk-lib.aws_sns.TopicProps | *No description.* | --- -##### `scope`Required +##### `scope`Required -- *Type:* constructs.IConstruct +- *Type:* constructs.Construct --- -##### `id`Required +##### `id`Required - *Type:* string --- -##### `props`Required +##### `props`Optional -- *Type:* SqsApproximateAgeOfOldestMessageAlarmProps +- *Type:* aws-cdk-lib.aws_sns.TopicProps --- @@ -14499,17 +18635,36 @@ new SqsApproximateAgeOfOldestMessageAlarm(scope: IConstruct, id: string, props: | **Name** | **Description** | | --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | +| addSubscription | Subscribe some endpoint to this topic. | +| addToResourcePolicy | Adds a statement to the IAM resource policy associated with this topic. | +| bindAsNotificationRuleTarget | Represents a notification target That allows SNS topic to associate with this rule target. | +| grantPublish | Grant topic publishing permissions to the given identity. | +| grantSubscribe | Grant topic subscribing permissions to the given identity. | +| metric | Return the given named metric for this Topic. | +| metricNumberOfMessagesPublished | The number of messages published to your Amazon SNS topics. | +| metricNumberOfNotificationsDelivered | The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints. | +| metricNumberOfNotificationsFailed | The number of messages that Amazon SNS failed to deliver. | +| metricNumberOfNotificationsFilteredOut | The number of messages that were rejected by subscription filter policies. | +| metricNumberOfNotificationsFilteredOutInvalidAttributes | The number of messages that were rejected by subscription filter policies because the messages' attributes are invalid. | +| metricNumberOfNotificationsFilteredOutNoMessageAttributes | The number of messages that were rejected by subscription filter policies because the messages have no attributes. | +| metricPublishSize | Metric for the size of messages published through this topic. | +| metricSMSMonthToDateSpentUSD | The charges you have accrued since the start of the current calendar month for sending SMS messages. | +| metricSMSSuccessRate | The rate of successful SMS message deliveries. | +| addLoggingConfig | Adds a delivery status logging configuration to the topic. | +| alarmNumberOfMessagesPublished | Creates an alarm for the NumberOfMessagesPublished metric. | +| alarmNumberOfNotificationsDelivered | Creates an alarm for the NumberOfNotificationsDelivered metric. | +| alarmNumberOfNotificationsFailed | Creates an alarm for the NumberOfNotificationsFailed metric. | +| alarmNumberOfNotificationsFailedToRedriveToDlq | Creates an alarm for the NumberOfNotificationsFailedToRedriveToDlq metric. | +| alarmNumberOfNotificationsFilteredOutInvalidAttributes | Creates an alarm for the NumberOfNotificationsFilteredOutInvalidAttributes metric. | +| alarmNumberOfNotificationsFilteredOutInvalidMessageBody | Creates an alarm for the NumberOfNotificationsFilteredOutInvalidMessageBody metric. | +| alarmNumberOfNotificationsRedrivenToDlq | Creates an alarm for the NumberOfNotificationsRedrivenToDlq metric. | +| applyRecommendedAlarms | Creates recommended alarms for the SNS topic. | --- -##### `toString` +##### `toString` ```typescript public toString(): string @@ -14517,7 +18672,7 @@ public toString(): string Returns a string representation of this construct. -##### `applyRemovalPolicy` +##### `applyRemovalPolicy` ```typescript public applyRemovalPolicy(policy: RemovalPolicy): void @@ -14533,509 +18688,401 @@ to be replaced. The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). -###### `policy`Required +###### `policy`Required - *Type:* aws-cdk-lib.RemovalPolicy --- -##### `addAlarmAction` +##### `addSubscription` ```typescript -public addAlarmAction(actions: IAlarmAction): void +public addSubscription(topicSubscription: ITopicSubscription): Subscription ``` -Trigger this action if the alarm fires. - -Typically SnsAction or AutoScalingAction. +Subscribe some endpoint to this topic. -###### `actions`Required +###### `topicSubscription`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* aws-cdk-lib.aws_sns.ITopicSubscription --- -##### `addInsufficientDataAction` +##### `addToResourcePolicy` ```typescript -public addInsufficientDataAction(actions: IAlarmAction): void +public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult ``` -Trigger this action if there is insufficient data to evaluate the alarm. +Adds a statement to the IAM resource policy associated with this topic. -Typically SnsAction or AutoScalingAction. +If this topic was created in this stack (`new Topic`), a topic policy +will be automatically created upon the first call to `addToResourcePolicy`. If +the topic is imported (`Topic.import`), then this is a no-op. -###### `actions`Required +###### `statement`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* aws-cdk-lib.aws_iam.PolicyStatement --- -##### `addOkAction` +##### `bindAsNotificationRuleTarget` ```typescript -public addOkAction(actions: IAlarmAction): void +public bindAsNotificationRuleTarget(_scope: Construct): NotificationRuleTargetConfig ``` -Trigger this action if the alarm returns from breaching state into ok state. - -Typically SnsAction or AutoScalingAction. +Represents a notification target That allows SNS topic to associate with this rule target. -###### `actions`Required +###### `_scope`Required -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* constructs.Construct --- -##### `renderAlarmRule` - -```typescript -public renderAlarmRule(): string -``` - -AlarmRule indicating ALARM state for Alarm. - -##### `toAnnotation` +##### `grantPublish` ```typescript -public toAnnotation(): HorizontalAnnotation +public grantPublish(grantee: IGrantable): Grant ``` -Turn this alarm into a horizontal annotation. - -This is useful if you want to represent an Alarm in a non-AlarmWidget. -An `AlarmWidget` can directly show an alarm, but it can only show a -single alarm and no other metrics. Instead, you can convert the alarm to -a HorizontalAnnotation and add it as an annotation to another graph. - -This might be useful if: - -- You want to show multiple alarms inside a single graph, for example if - you have both a "small margin/long period" alarm as well as a - "large margin/short period" alarm. - -- You want to show an Alarm line in a graph with multiple metrics in it. +Grant topic publishing permissions to the given identity. -#### Static Functions +###### `grantee`Required -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +- *Type:* aws-cdk-lib.aws_iam.IGrantable --- -##### ~~`isConstruct`~~ +##### `grantSubscribe` ```typescript -import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateAgeOfOldestMessageAlarm.isConstruct(x: any) +public grantSubscribe(grantee: IGrantable): Grant ``` -Checks if `x` is a construct. - -###### `x`Required +Grant topic subscribing permissions to the given identity. -- *Type:* any +###### `grantee`Required -Any object. +- *Type:* aws-cdk-lib.aws_iam.IGrantable --- -##### `isOwnedResource` +##### `metric` ```typescript -import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateAgeOfOldestMessageAlarm.isOwnedResource(construct: IConstruct) +public metric(metricName: string, props?: MetricOptions): Metric ``` -Returns true if the construct was created by CDK, and false otherwise. +Return the given named metric for this Topic. -###### `construct`Required +###### `metricName`Required -- *Type:* constructs.IConstruct +- *Type:* string --- -##### `isResource` - -```typescript -import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateAgeOfOldestMessageAlarm.isResource(construct: IConstruct) -``` - -Check whether the given construct is a Resource. - -###### `construct`Required +###### `props`Optional -- *Type:* constructs.IConstruct +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `fromAlarmArn` +##### `metricNumberOfMessagesPublished` ```typescript -import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateAgeOfOldestMessageAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +public metricNumberOfMessagesPublished(props?: MetricOptions): Metric ``` -Import an existing CloudWatch alarm provided an ARN. +The number of messages published to your Amazon SNS topics. -###### `scope`Required +Sum over 5 minutes -- *Type:* constructs.Construct +###### `props`Optional -The parent creating construct (usually `this`). +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -###### `id`Required - -- *Type:* string +##### `metricNumberOfNotificationsDelivered` -The construct's name. +```typescript +public metricNumberOfNotificationsDelivered(props?: MetricOptions): Metric +``` ---- +The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints. -###### `alarmArn`Required +Sum over 5 minutes -- *Type:* string +###### `props`Optional -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `fromAlarmName` +##### `metricNumberOfNotificationsFailed` ```typescript -import { SqsApproximateAgeOfOldestMessageAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateAgeOfOldestMessageAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +public metricNumberOfNotificationsFailed(props?: MetricOptions): Metric ``` -Import an existing CloudWatch alarm provided an Name. - -###### `scope`Required - -- *Type:* constructs.Construct - -The parent creating construct (usually `this`). - ---- +The number of messages that Amazon SNS failed to deliver. -###### `id`Required +Sum over 5 minutes -- *Type:* string +###### `props`Optional -The construct's name. +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -###### `alarmName`Required +##### `metricNumberOfNotificationsFilteredOut` -- *Type:* string +```typescript +public metricNumberOfNotificationsFilteredOut(props?: MetricOptions): Metric +``` -Alarm Name. +The number of messages that were rejected by subscription filter policies. ---- +Sum over 5 minutes -#### Properties +###### `props`Optional -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `node`Required +##### `metricNumberOfNotificationsFilteredOutInvalidAttributes` ```typescript -public readonly node: Node; +public metricNumberOfNotificationsFilteredOutInvalidAttributes(props?: MetricOptions): Metric ``` -- *Type:* constructs.Node +The number of messages that were rejected by subscription filter policies because the messages' attributes are invalid. -The tree node. +Sum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `env`Required +##### `metricNumberOfNotificationsFilteredOutNoMessageAttributes` ```typescript -public readonly env: ResourceEnvironment; +public metricNumberOfNotificationsFilteredOutNoMessageAttributes(props?: MetricOptions): Metric ``` -- *Type:* aws-cdk-lib.ResourceEnvironment +The number of messages that were rejected by subscription filter policies because the messages have no attributes. -The environment this resource belongs to. +Sum over 5 minutes -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `stack`Required +##### `metricPublishSize` ```typescript -public readonly stack: Stack; +public metricPublishSize(props?: MetricOptions): Metric ``` -- *Type:* aws-cdk-lib.Stack - -The stack in which this resource is defined. - ---- - -##### `alarmArn`Required +Metric for the size of messages published through this topic. -```typescript -public readonly alarmArn: string; -``` +Average over 5 minutes -- *Type:* string +###### `props`Optional -ARN of this alarm. +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `alarmName`Required +##### `metricSMSMonthToDateSpentUSD` ```typescript -public readonly alarmName: string; +public metricSMSMonthToDateSpentUSD(props?: MetricOptions): Metric ``` -- *Type:* string +The charges you have accrued since the start of the current calendar month for sending SMS messages. -Name of this alarm. +Maximum over 5 minutes + +###### `props`Optional + +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions --- -##### `metric`Required +##### `metricSMSSuccessRate` ```typescript -public readonly metric: IMetric; +public metricSMSSuccessRate(props?: MetricOptions): Metric ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric - -The metric object this alarm was based on. - ---- - +The rate of successful SMS message deliveries. -### SqsApproximateNumberOfMessagesNotVisibleAlarm +Sum over 5 minutes -An alarm that watches the number of messages that are in flight. +###### `props`Optional -This alarm is used to detect a high number of in-flight messages -in the queue. If consumers do not delete messages within the -visibility timeout period, when the queue is polled, messages -reappear in the queue. For FIFO queues, there can be a maximum -of 20,000 in-flight messages. If you reach this quota, SQS returns -no error messages. A FIFO queue looks through the first 20k -messages to determine available message groups. This means that -if you have a backlog of messages in a single message group, -you cannot consume messages from other message groups that were -sent to the queue at a later time until you successfully -consume the messages from the backlog. +- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions -This alarm is triggered when the number of messages that are in -flight exceeds or is equal to the specified threshold. +--- -#### Initializers +##### `addLoggingConfig` ```typescript -import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -new SqsApproximateNumberOfMessagesNotVisibleAlarm(scope: IConstruct, id: string, props: SqsApproximateNumberOfMessagesNotVisibleAlarmProps) +public addLoggingConfig(config: LoggingConfig): void ``` -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SqsApproximateNumberOfMessagesNotVisibleAlarmProps | *No description.* | - ---- +Adds a delivery status logging configuration to the topic. -##### `scope`Required +###### `config`Required -- *Type:* constructs.IConstruct +- *Type:* aws-cdk-lib.aws_sns.LoggingConfig --- -##### `id`Required +##### `alarmNumberOfMessagesPublished` -- *Type:* string +```typescript +public alarmNumberOfMessagesPublished(props: SnsNumberOfMessagesPublishedAlarmConfig): SnsNumberOfMessagesPublishedAlarm +``` ---- +Creates an alarm for the NumberOfMessagesPublished metric. -##### `props`Required +###### `props`Required -- *Type:* SqsApproximateNumberOfMessagesNotVisibleAlarmProps +- *Type:* SnsNumberOfMessagesPublishedAlarmConfig --- -#### Methods +##### `alarmNumberOfNotificationsDelivered` -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +```typescript +public alarmNumberOfNotificationsDelivered(props: SnsNumberOfNotificationsDeliveredAlarmConfig): SnsNumberOfNotificationsDeliveredAlarm +``` ---- +Creates an alarm for the NumberOfNotificationsDelivered metric. -##### `toString` +###### `props`Required -```typescript -public toString(): string -``` +- *Type:* SnsNumberOfNotificationsDeliveredAlarmConfig -Returns a string representation of this construct. +--- -##### `applyRemovalPolicy` +##### `alarmNumberOfNotificationsFailed` ```typescript -public applyRemovalPolicy(policy: RemovalPolicy): void +public alarmNumberOfNotificationsFailed(props: SnsNumberOfNotificationsFailedAlarmConfig): SnsNumberOfNotificationsFailedAlarm ``` -Apply the given removal policy to this resource. - -The Removal Policy controls what happens to this resource when it stops -being managed by CloudFormation, either because you've removed it from the -CDK application or because you've made a change that requires the resource -to be replaced. - -The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS -account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). +Creates an alarm for the NumberOfNotificationsFailed metric. -###### `policy`Required +###### `props`Required -- *Type:* aws-cdk-lib.RemovalPolicy +- *Type:* SnsNumberOfNotificationsFailedAlarmConfig --- -##### `addAlarmAction` +##### `alarmNumberOfNotificationsFailedToRedriveToDlq` ```typescript -public addAlarmAction(actions: IAlarmAction): void +public alarmNumberOfNotificationsFailedToRedriveToDlq(props?: SnsNumberOfNotificationsFailedToRedriveToDlqAlarmConfig): SnsNumberOfNotificationsFailedToRedriveToDlqAlarm ``` -Trigger this action if the alarm fires. - -Typically SnsAction or AutoScalingAction. +Creates an alarm for the NumberOfNotificationsFailedToRedriveToDlq metric. -###### `actions`Required +###### `props`Optional -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* SnsNumberOfNotificationsFailedToRedriveToDlqAlarmConfig --- -##### `addInsufficientDataAction` +##### `alarmNumberOfNotificationsFilteredOutInvalidAttributes` ```typescript -public addInsufficientDataAction(actions: IAlarmAction): void +public alarmNumberOfNotificationsFilteredOutInvalidAttributes(props?: SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmConfig): SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm ``` -Trigger this action if there is insufficient data to evaluate the alarm. - -Typically SnsAction or AutoScalingAction. +Creates an alarm for the NumberOfNotificationsFilteredOutInvalidAttributes metric. -###### `actions`Required +###### `props`Optional -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmConfig --- -##### `addOkAction` +##### `alarmNumberOfNotificationsFilteredOutInvalidMessageBody` ```typescript -public addOkAction(actions: IAlarmAction): void +public alarmNumberOfNotificationsFilteredOutInvalidMessageBody(props?: SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmConfig): SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm ``` -Trigger this action if the alarm returns from breaching state into ok state. - -Typically SnsAction or AutoScalingAction. +Creates an alarm for the NumberOfNotificationsFilteredOutInvalidMessageBody metric. -###### `actions`Required +###### `props`Optional -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Type:* SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmConfig --- -##### `renderAlarmRule` +##### `alarmNumberOfNotificationsRedrivenToDlq` ```typescript -public renderAlarmRule(): string +public alarmNumberOfNotificationsRedrivenToDlq(props?: SnsNumberOfNotificationsRedrivenToDlqAlarmConfig): SnsNumberOfNotificationsRedrivenToDlqAlarm ``` -AlarmRule indicating ALARM state for Alarm. +Creates an alarm for the NumberOfNotificationsRedrivenToDlq metric. -##### `toAnnotation` +###### `props`Optional + +- *Type:* SnsNumberOfNotificationsRedrivenToDlqAlarmConfig + +--- + +##### `applyRecommendedAlarms` ```typescript -public toAnnotation(): HorizontalAnnotation +public applyRecommendedAlarms(props: SnsRecommendedAlarmsConfig): SnsRecommendedAlarms ``` -Turn this alarm into a horizontal annotation. +Creates recommended alarms for the SNS topic. -This is useful if you want to represent an Alarm in a non-AlarmWidget. -An `AlarmWidget` can directly show an alarm, but it can only show a -single alarm and no other metrics. Instead, you can convert the alarm to -a HorizontalAnnotation and add it as an annotation to another graph. +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS) -This might be useful if: +###### `props`Required -- You want to show multiple alarms inside a single graph, for example if - you have both a "small margin/long period" alarm as well as a - "large margin/short period" alarm. +- *Type:* SnsRecommendedAlarmsConfig -- You want to show an Alarm line in a graph with multiple metrics in it. +--- #### Static Functions | **Name** | **Description** | | --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromTopicArn | Import an existing SNS topic provided an ARN. | +| fromTopicAttributes | Import an existing SNS topic provided a topic attributes. | --- -##### ~~`isConstruct`~~ +##### ~~`isConstruct`~~ ```typescript -import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SqsApproximateNumberOfMessagesNotVisibleAlarm.isConstruct(x: any) +Topic.isConstruct(x: any) ``` Checks if `x` is a construct. -###### `x`Required +###### `x`Required - *Type:* any @@ -15043,57 +19090,57 @@ Any object. --- -##### `isOwnedResource` +##### `isOwnedResource` ```typescript -import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SqsApproximateNumberOfMessagesNotVisibleAlarm.isOwnedResource(construct: IConstruct) +Topic.isOwnedResource(construct: IConstruct) ``` Returns true if the construct was created by CDK, and false otherwise. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `isResource` +##### `isResource` ```typescript -import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SqsApproximateNumberOfMessagesNotVisibleAlarm.isResource(construct: IConstruct) +Topic.isResource(construct: IConstruct) ``` Check whether the given construct is a Resource. -###### `construct`Required +###### `construct`Required - *Type:* constructs.IConstruct --- -##### `fromAlarmArn` +##### `fromTopicArn` ```typescript -import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SqsApproximateNumberOfMessagesNotVisibleAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +Topic.fromTopicArn(scope: Construct, id: string, topicArn: string) ``` -Import an existing CloudWatch alarm provided an ARN. +Import an existing SNS topic provided an ARN. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct -The parent creating construct (usually `this`). +The parent creating construct. --- -###### `id`Required +###### `id`Required - *Type:* string @@ -15101,33 +19148,33 @@ The construct's name. --- -###### `alarmArn`Required +###### `topicArn`Required - *Type:* string -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). +topic ARN (i.e. arn:aws:sns:us-east-2:444455556666:MyTopic). --- -##### `fromAlarmName` +##### `fromTopicAttributes` ```typescript -import { SqsApproximateNumberOfMessagesNotVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' -SqsApproximateNumberOfMessagesNotVisibleAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +Topic.fromTopicAttributes(scope: Construct, id: string, attrs: TopicAttributes) ``` -Import an existing CloudWatch alarm provided an Name. +Import an existing SNS topic provided a topic attributes. -###### `scope`Required +###### `scope`Required - *Type:* constructs.Construct -The parent creating construct (usually `this`). +The parent creating construct. --- -###### `id`Required +###### `id`Required - *Type:* string @@ -15135,11 +19182,11 @@ The construct's name. --- -###### `alarmName`Required +###### `attrs`Required -- *Type:* string +- *Type:* aws-cdk-lib.aws_sns.TopicAttributes -Alarm Name. +the attributes of the topic to import. --- @@ -15147,16 +19194,17 @@ Alarm Name. | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| contentBasedDeduplication | boolean | Enables content-based deduplication for FIFO topics. | +| fifo | boolean | Whether this topic is an Amazon SNS FIFO queue. | +| topicArn | string | The ARN of the topic. | +| topicName | string | The name of the topic. | --- -##### `node`Required +##### `node`Required ```typescript public readonly node: Node; @@ -15168,7 +19216,7 @@ The tree node. --- -##### `env`Required +##### `env`Required ```typescript public readonly env: ResourceEnvironment; @@ -15187,7 +19235,7 @@ that might be different than the stack they were imported into. --- -##### `stack`Required +##### `stack`Required ```typescript public readonly stack: Stack; @@ -15199,1703 +19247,1807 @@ The stack in which this resource is defined. --- -##### `alarmArn`Required +##### `contentBasedDeduplication`Required ```typescript -public readonly alarmArn: string; +public readonly contentBasedDeduplication: boolean; ``` -- *Type:* string +- *Type:* boolean -ARN of this alarm. +Enables content-based deduplication for FIFO topics. --- -##### `alarmName`Required +##### `fifo`Required ```typescript -public readonly alarmName: string; +public readonly fifo: boolean; ``` -- *Type:* string +- *Type:* boolean -Name of this alarm. +Whether this topic is an Amazon SNS FIFO queue. + +If false, this is a standard topic. --- -##### `metric`Required +##### `topicArn`Required ```typescript -public readonly metric: IMetric; +public readonly topicArn: string; ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +- *Type:* string -The metric object this alarm was based on. +The ARN of the topic. --- +##### `topicName`Required -### SqsApproximateNumberOfMessagesVisibleAlarm +```typescript +public readonly topicName: string; +``` -An alarm that watches the number of messages that are visible in the queue. +- *Type:* string -This alarm is used to detect whether the message -count of the active queue is too high and consumers -are slow to process the messages or there are not -enough consumers to process them. +The name of the topic. -This alarm is triggered when the number of messages -that are visible in the queue exceeds or is equal to -the specified threshold. +--- -#### Initializers + +## Structs + +### AlarmBaseProps + +The base properties for an alarm where default values are consistent across all alarms. + +#### Initializer ```typescript -import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { AlarmBaseProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SqsApproximateNumberOfMessagesVisibleAlarm(scope: IConstruct, id: string, props: SqsApproximateNumberOfMessagesVisibleAlarmProps) +const alarmBaseProps: AlarmBaseProps = { ... } ``` +#### Properties + | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SqsApproximateNumberOfMessagesVisibleAlarmProps | *No description.* | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | --- -##### `scope`Required - -- *Type:* constructs.IConstruct +##### `alarmAction`Optional ---- +```typescript +public readonly alarmAction: IAlarmAction; +``` -##### `id`Required +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -- *Type:* string +The action to take when an alarm is triggered. --- -##### `props`Required - -- *Type:* SqsApproximateNumberOfMessagesVisibleAlarmProps +##### `insufficientDataAction`Optional ---- +```typescript +public readonly insufficientDataAction: IAlarmAction; +``` -#### Methods +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +The action to take when an alarm has insufficient data. --- -##### `toString` +##### `okAction`Optional ```typescript -public toString(): string +public readonly okAction: IAlarmAction; ``` -Returns a string representation of this construct. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -##### `applyRemovalPolicy` +The action to take when an alarm enters the ok state. + +--- + +##### `treatMissingData`Optional ```typescript -public applyRemovalPolicy(policy: RemovalPolicy): void +public readonly treatMissingData: TreatMissingData; ``` -Apply the given removal policy to this resource. - -The Removal Policy controls what happens to this resource when it stops -being managed by CloudFormation, either because you've removed it from the -CDK application or because you've made a change that requires the resource -to be replaced. +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS -account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). +How to handle missing data for this alarm. -###### `policy`Required +--- -- *Type:* aws-cdk-lib.RemovalPolicy +### EcsAlarmBaseConfig ---- +The common optional configuration for the alarms. -##### `addAlarmAction` +#### Initializer ```typescript -public addAlarmAction(actions: IAlarmAction): void +import { EcsAlarmBaseConfig } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +const ecsAlarmBaseConfig: EcsAlarmBaseConfig = { ... } ``` -Trigger this action if the alarm fires. +#### Properties -Typically SnsAction or AutoScalingAction. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | -###### `actions`Required +--- + +##### `alarmAction`Optional + +```typescript +public readonly alarmAction: IAlarmAction; +``` - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm is triggered. --- -##### `addInsufficientDataAction` +##### `insufficientDataAction`Optional ```typescript -public addInsufficientDataAction(actions: IAlarmAction): void +public readonly insufficientDataAction: IAlarmAction; ``` -Trigger this action if there is insufficient data to evaluate the alarm. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -Typically SnsAction or AutoScalingAction. +The action to take when an alarm has insufficient data. -###### `actions`Required +--- + +##### `okAction`Optional + +```typescript +public readonly okAction: IAlarmAction; +``` - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm enters the ok state. --- -##### `addOkAction` +##### `treatMissingData`Optional ```typescript -public addOkAction(actions: IAlarmAction): void +public readonly treatMissingData: TreatMissingData; ``` -Trigger this action if the alarm returns from breaching state into ok state. - -Typically SnsAction or AutoScalingAction. - -###### `actions`Required +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +How to handle missing data for this alarm. --- -##### `renderAlarmRule` +##### `period`Optional ```typescript -public renderAlarmRule(): string +public readonly period: Duration; ``` -AlarmRule indicating ALARM state for Alarm. +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) -##### `toAnnotation` +The period over which the specified statistic is applied. + +--- + +### EcsCpuUtilizationAlarmConfig + +Configuration for the CpuUtilization alarm. + +#### Initializer ```typescript -public toAnnotation(): HorizontalAnnotation +import { EcsCpuUtilizationAlarmConfig } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +const ecsCpuUtilizationAlarmConfig: EcsCpuUtilizationAlarmConfig = { ... } ``` -Turn this alarm into a horizontal annotation. +#### Properties -This is useful if you want to represent an Alarm in a non-AlarmWidget. -An `AlarmWidget` can directly show an alarm, but it can only show a -single alarm and no other metrics. Instead, you can convert the alarm to -a HorizontalAnnotation and add it as an annotation to another graph. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | +| threshold | number | The percentage (0-100) value against which the specified statistic is compared. | -This might be useful if: +--- -- You want to show multiple alarms inside a single graph, for example if - you have both a "small margin/long period" alarm as well as a - "large margin/short period" alarm. +##### `alarmAction`Optional -- You want to show an Alarm line in a graph with multiple metrics in it. +```typescript +public readonly alarmAction: IAlarmAction; +``` -#### Static Functions +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +The action to take when an alarm is triggered. --- -##### ~~`isConstruct`~~ +##### `insufficientDataAction`Optional ```typescript -import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateNumberOfMessagesVisibleAlarm.isConstruct(x: any) +public readonly insufficientDataAction: IAlarmAction; ``` -Checks if `x` is a construct. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -###### `x`Required +The action to take when an alarm has insufficient data. + +--- + +##### `okAction`Optional + +```typescript +public readonly okAction: IAlarmAction; +``` -- *Type:* any +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -Any object. +The action to take when an alarm enters the ok state. --- -##### `isOwnedResource` +##### `treatMissingData`Optional ```typescript -import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateNumberOfMessagesVisibleAlarm.isOwnedResource(construct: IConstruct) +public readonly treatMissingData: TreatMissingData; ``` -Returns true if the construct was created by CDK, and false otherwise. - -###### `construct`Required +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -- *Type:* constructs.IConstruct +How to handle missing data for this alarm. --- -##### `isResource` +##### `period`Optional ```typescript -import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateNumberOfMessagesVisibleAlarm.isResource(construct: IConstruct) +public readonly period: Duration; ``` -Check whether the given construct is a Resource. - -###### `construct`Required +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) -- *Type:* constructs.IConstruct +The period over which the specified statistic is applied. --- -##### `fromAlarmArn` +##### `alarmDescription`Optional ```typescript -import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateNumberOfMessagesVisibleAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) +public readonly alarmDescription: string; ``` -Import an existing CloudWatch alarm provided an ARN. - -###### `scope`Required - -- *Type:* constructs.Construct +- *Type:* string +- *Default:* This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems. -The parent creating construct (usually `this`). +The description of the alarm. --- -###### `id`Required +##### `alarmName`Optional + +```typescript +public readonly alarmName: string; +``` - *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - CPUUtilization' -The construct's name. +The alarm name. --- -###### `alarmArn`Required +##### `datapointsToAlarm`Optional -- *Type:* string +```typescript +public readonly datapointsToAlarm: number; +``` -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). +- *Type:* number +- *Default:* 5 + +The number of data points that must be breaching to trigger the alarm. --- -##### `fromAlarmName` +##### `evaluationPeriods`Optional ```typescript -import { SqsApproximateNumberOfMessagesVisibleAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsApproximateNumberOfMessagesVisibleAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +public readonly evaluationPeriods: number; ``` -Import an existing CloudWatch alarm provided an Name. +- *Type:* number +- *Default:* 5 -###### `scope`Required +The number of periods over which data is compared to the specified threshold. -- *Type:* constructs.Construct +--- -The parent creating construct (usually `this`). +##### `threshold`Optional ---- +```typescript +public readonly threshold: number; +``` -###### `id`Required +- *Type:* number +- *Default:* 90 -- *Type:* string +The percentage (0-100) value against which the specified statistic is compared. -The construct's name. +The service metrics for CPU utilization might exceed 100% utilization. However, +we recommend that you monitor the metric for high CPU utilization to avoid impacting +other services. Set the threshold to about 90-95%. We recommend that you update your +task definitions to reflect actual usage to prevent future issues with other services. --- -###### `alarmName`Required +### EcsEphemeralStorageUtilizedAlarmConfig -- *Type:* string +Configuration for the EphemeralStorageUtilized alarm. -Alarm Name. +#### Initializer ---- +```typescript +import { EcsEphemeralStorageUtilizedAlarmConfig } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +const ecsEphemeralStorageUtilizedAlarmConfig: EcsEphemeralStorageUtilizedAlarmConfig = { ... } +``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| threshold | number | The value in GB against which the specified statistic is compared. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | --- -##### `node`Required +##### `alarmAction`Optional ```typescript -public readonly node: Node; +public readonly alarmAction: IAlarmAction; ``` -- *Type:* constructs.Node +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -The tree node. +The action to take when an alarm is triggered. --- -##### `env`Required +##### `insufficientDataAction`Optional ```typescript -public readonly env: ResourceEnvironment; +public readonly insufficientDataAction: IAlarmAction; ``` -- *Type:* aws-cdk-lib.ResourceEnvironment - -The environment this resource belongs to. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +The action to take when an alarm has insufficient data. --- -##### `stack`Required +##### `okAction`Optional ```typescript -public readonly stack: Stack; +public readonly okAction: IAlarmAction; ``` -- *Type:* aws-cdk-lib.Stack +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -The stack in which this resource is defined. +The action to take when an alarm enters the ok state. --- -##### `alarmArn`Required +##### `treatMissingData`Optional ```typescript -public readonly alarmArn: string; +public readonly treatMissingData: TreatMissingData; ``` -- *Type:* string +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -ARN of this alarm. +How to handle missing data for this alarm. --- -##### `alarmName`Required +##### `period`Optional ```typescript -public readonly alarmName: string; +public readonly period: Duration; ``` -- *Type:* string +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) -Name of this alarm. +The period over which the specified statistic is applied. --- -##### `metric`Required +##### `threshold`Required ```typescript -public readonly metric: IMetric; +public readonly threshold: number; ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +- *Type:* number -The metric object this alarm was based on. +The value in GB against which the specified statistic is compared. + +Set the threshold to about 90% of the ephemeral storage size. You can adjust this +value based on your acceptable ephemeral storage utilization of the Fargate cluster. +For some systems, a consistently high ephemeral storage utilized might be normal, +while for others, it might lead to failure of the container. --- +##### `alarmDescription`Optional -### SqsNumberOfMessagesSentAlarm +```typescript +public readonly alarmDescription: string; +``` -An alarm that watches the number of messages that are sent. +- *Type:* string +- *Default:* This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container. -This alarm is used to detect when a producer stops sending messages. +The description of the alarm. -This alarm is triggered when the number of messages sent is less than -or equal to the specified threshold. By default, 0. +--- -#### Initializers +##### `alarmName`Optional ```typescript -import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -new SqsNumberOfMessagesSentAlarm(scope: IConstruct, id: string, props: SqsNumberOfMessagesSentAlarmProps) +public readonly alarmName: string; ``` -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| scope | constructs.IConstruct | *No description.* | -| id | string | *No description.* | -| props | SqsNumberOfMessagesSentAlarmProps | *No description.* | +- *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - EphemeralStorageUtilized' ---- +The alarm name. -##### `scope`Required +--- -- *Type:* constructs.IConstruct +##### `datapointsToAlarm`Optional ---- +```typescript +public readonly datapointsToAlarm: number; +``` -##### `id`Required +- *Type:* number +- *Default:* 5 -- *Type:* string +The number of data points that must be breaching to trigger the alarm. --- -##### `props`Required - -- *Type:* SqsNumberOfMessagesSentAlarmProps +##### `evaluationPeriods`Optional ---- +```typescript +public readonly evaluationPeriods: number; +``` -#### Methods +- *Type:* number +- *Default:* 5 -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addAlarmAction | Trigger this action if the alarm fires. | -| addInsufficientDataAction | Trigger this action if there is insufficient data to evaluate the alarm. | -| addOkAction | Trigger this action if the alarm returns from breaching state into ok state. | -| renderAlarmRule | AlarmRule indicating ALARM state for Alarm. | -| toAnnotation | Turn this alarm into a horizontal annotation. | +The number of periods over which data is compared to the specified threshold. --- -##### `toString` - -```typescript -public toString(): string -``` +### EcsMemoryUtilizationAlarmConfig -Returns a string representation of this construct. +Configuration for the MemoryUtilization alarm. -##### `applyRemovalPolicy` +#### Initializer ```typescript -public applyRemovalPolicy(policy: RemovalPolicy): void -``` - -Apply the given removal policy to this resource. - -The Removal Policy controls what happens to this resource when it stops -being managed by CloudFormation, either because you've removed it from the -CDK application or because you've made a change that requires the resource -to be replaced. +import { EcsMemoryUtilizationAlarmConfig } from '@renovosolutions/cdk-library-cloudwatch-alarms' -The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS -account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). +const ecsMemoryUtilizationAlarmConfig: EcsMemoryUtilizationAlarmConfig = { ... } +``` -###### `policy`Required +#### Properties -- *Type:* aws-cdk-lib.RemovalPolicy +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | +| threshold | number | The percentage (0-100) value against which the specified statistic is compared. | --- -##### `addAlarmAction` +##### `alarmAction`Optional ```typescript -public addAlarmAction(actions: IAlarmAction): void +public readonly alarmAction: IAlarmAction; ``` -Trigger this action if the alarm fires. - -Typically SnsAction or AutoScalingAction. - -###### `actions`Required - - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm is triggered. --- -##### `addInsufficientDataAction` +##### `insufficientDataAction`Optional ```typescript -public addInsufficientDataAction(actions: IAlarmAction): void +public readonly insufficientDataAction: IAlarmAction; ``` -Trigger this action if there is insufficient data to evaluate the alarm. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -Typically SnsAction or AutoScalingAction. +The action to take when an alarm has insufficient data. -###### `actions`Required +--- + +##### `okAction`Optional + +```typescript +public readonly okAction: IAlarmAction; +``` - *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm enters the ok state. --- -##### `addOkAction` +##### `treatMissingData`Optional ```typescript -public addOkAction(actions: IAlarmAction): void +public readonly treatMissingData: TreatMissingData; ``` -Trigger this action if the alarm returns from breaching state into ok state. - -Typically SnsAction or AutoScalingAction. - -###### `actions`Required +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +How to handle missing data for this alarm. --- -##### `renderAlarmRule` +##### `period`Optional ```typescript -public renderAlarmRule(): string +public readonly period: Duration; ``` -AlarmRule indicating ALARM state for Alarm. +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) -##### `toAnnotation` +The period over which the specified statistic is applied. + +--- + +##### `alarmDescription`Optional ```typescript -public toAnnotation(): HorizontalAnnotation +public readonly alarmDescription: string; ``` -Turn this alarm into a horizontal annotation. +- *Type:* string +- *Default:* This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems. -This is useful if you want to represent an Alarm in a non-AlarmWidget. -An `AlarmWidget` can directly show an alarm, but it can only show a -single alarm and no other metrics. Instead, you can convert the alarm to -a HorizontalAnnotation and add it as an annotation to another graph. +The description of the alarm. -This might be useful if: +--- -- You want to show multiple alarms inside a single graph, for example if - you have both a "small margin/long period" alarm as well as a - "large margin/short period" alarm. +##### `alarmName`Optional -- You want to show an Alarm line in a graph with multiple metrics in it. +```typescript +public readonly alarmName: string; +``` -#### Static Functions +- *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - MemoryUtilization' -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromAlarmArn | Import an existing CloudWatch alarm provided an ARN. | -| fromAlarmName | Import an existing CloudWatch alarm provided an Name. | +The alarm name. --- -##### ~~`isConstruct`~~ +##### `datapointsToAlarm`Optional ```typescript -import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsNumberOfMessagesSentAlarm.isConstruct(x: any) +public readonly datapointsToAlarm: number; ``` -Checks if `x` is a construct. - -###### `x`Required - -- *Type:* any +- *Type:* number +- *Default:* 5 -Any object. +The number of data points that must be breaching to trigger the alarm. --- -##### `isOwnedResource` +##### `evaluationPeriods`Optional ```typescript -import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsNumberOfMessagesSentAlarm.isOwnedResource(construct: IConstruct) +public readonly evaluationPeriods: number; ``` -Returns true if the construct was created by CDK, and false otherwise. - -###### `construct`Required +- *Type:* number +- *Default:* 5 -- *Type:* constructs.IConstruct +The number of periods over which data is compared to the specified threshold. --- -##### `isResource` +##### `threshold`Optional ```typescript -import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsNumberOfMessagesSentAlarm.isResource(construct: IConstruct) +public readonly threshold: number; ``` -Check whether the given construct is a Resource. +- *Type:* number +- *Default:* 90 -###### `construct`Required +The percentage (0-100) value against which the specified statistic is compared. -- *Type:* constructs.IConstruct +The memory utilization is measured as the total memory in use by the tasks that +belong to the service, divided by the total memory reserved for the tasks that +belong to the service. --- -##### `fromAlarmArn` +### EcsRunningTaskCountAlarmConfig -```typescript -import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' +Configuration for the RunningTaskCount alarm. -SqsNumberOfMessagesSentAlarm.fromAlarmArn(scope: Construct, id: string, alarmArn: string) -``` +#### Initializer -Import an existing CloudWatch alarm provided an ARN. +```typescript +import { EcsRunningTaskCountAlarmConfig } from '@renovosolutions/cdk-library-cloudwatch-alarms' -###### `scope`Required +const ecsRunningTaskCountAlarmConfig: EcsRunningTaskCountAlarmConfig = { ... } +``` -- *Type:* constructs.Construct +#### Properties -The parent creating construct (usually `this`). +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | +| threshold | number | The value against which the specified statistic is compared. | --- -###### `id`Required +##### `alarmAction`Optional -- *Type:* string +```typescript +public readonly alarmAction: IAlarmAction; +``` -The construct's name. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm is triggered. --- -###### `alarmArn`Required +##### `insufficientDataAction`Optional -- *Type:* string +```typescript +public readonly insufficientDataAction: IAlarmAction; +``` -Alarm ARN (i.e. arn:aws:cloudwatch:::alarm:Foo). +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm has insufficient data. --- -##### `fromAlarmName` +##### `okAction`Optional ```typescript -import { SqsNumberOfMessagesSentAlarm } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsNumberOfMessagesSentAlarm.fromAlarmName(scope: Construct, id: string, alarmName: string) +public readonly okAction: IAlarmAction; ``` -Import an existing CloudWatch alarm provided an Name. - -###### `scope`Required - -- *Type:* constructs.Construct +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -The parent creating construct (usually `this`). +The action to take when an alarm enters the ok state. --- -###### `id`Required +##### `treatMissingData`Optional -- *Type:* string +```typescript +public readonly treatMissingData: TreatMissingData; +``` -The construct's name. +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING + +How to handle missing data for this alarm. --- -###### `alarmName`Required +##### `period`Optional -- *Type:* string +```typescript +public readonly period: Duration; +``` -Alarm Name. +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) + +The period over which the specified statistic is applied. --- -#### Properties +##### `alarmDescription`Optional -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| alarmArn | string | ARN of this alarm. | -| alarmName | string | Name of this alarm. | -| metric | aws-cdk-lib.aws_cloudwatch.IMetric | The metric object this alarm was based on. | +```typescript +public readonly alarmDescription: string; +``` + +- *Type:* string +- *Default:* This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues. + +The description of the alarm. --- -##### `node`Required +##### `alarmName`Optional ```typescript -public readonly node: Node; +public readonly alarmName: string; ``` -- *Type:* constructs.Node +- *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - RunningTaskCount' -The tree node. +The alarm name. --- -##### `env`Required +##### `datapointsToAlarm`Optional ```typescript -public readonly env: ResourceEnvironment; +public readonly datapointsToAlarm: number; ``` -- *Type:* aws-cdk-lib.ResourceEnvironment - -The environment this resource belongs to. +- *Type:* number +- *Default:* 5 -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +The number of data points that must be breaching to trigger the alarm. --- -##### `stack`Required +##### `evaluationPeriods`Optional ```typescript -public readonly stack: Stack; +public readonly evaluationPeriods: number; ``` -- *Type:* aws-cdk-lib.Stack +- *Type:* number +- *Default:* 5 -The stack in which this resource is defined. +The number of periods over which data is compared to the specified threshold. --- -##### `alarmArn`Required +##### `threshold`Optional ```typescript -public readonly alarmArn: string; +public readonly threshold: number; ``` -- *Type:* string +- *Type:* number +- *Default:* 0 -ARN of this alarm. +The value against which the specified statistic is compared. + +You can adjust the threshold based on the minimum running task count of the ECS +service. If the running task count is 0, the Amazon ECS service will be unavailable. --- -##### `alarmName`Required +### EcsServiceAlarmProps + +The common properties for the ECS service alarms. + +#### Initializer ```typescript -public readonly alarmName: string; +import { EcsServiceAlarmProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +const ecsServiceAlarmProps: EcsServiceAlarmProps = { ... } ``` -- *Type:* string +#### Properties -Name of this alarm. +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| service | aws-cdk-lib.aws_ecs.FargateService | The ECS service to monitor. | --- -##### `metric`Required +##### `service`Required ```typescript -public readonly metric: IMetric; +public readonly service: FargateService; ``` -- *Type:* aws-cdk-lib.aws_cloudwatch.IMetric +- *Type:* aws-cdk-lib.aws_ecs.FargateService -The metric object this alarm was based on. +The ECS service to monitor. --- +### EcsServiceCpuUtilizationAlarmProps -### SqsRecommendedAlarms +The properties for the EcsServiceCpuUtilizationAlarm construct. -#### Initializers +#### Initializer ```typescript -import { SqsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceCpuUtilizationAlarmProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new SqsRecommendedAlarms(scope: Construct, id: string, props: SqsRecommendedAlarmsProps) +const ecsServiceCpuUtilizationAlarmProps: EcsServiceCpuUtilizationAlarmProps = { ... } ``` +#### Properties + | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | SqsRecommendedAlarmsProps | *No description.* | +| service | aws-cdk-lib.aws_ecs.FargateService | The ECS service to monitor. | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | +| threshold | number | The percentage (0-100) value against which the specified statistic is compared. | --- -##### `scope`Required - -- *Type:* constructs.Construct +##### `service`Required ---- +```typescript +public readonly service: FargateService; +``` -##### `id`Required +- *Type:* aws-cdk-lib.aws_ecs.FargateService -- *Type:* string +The ECS service to monitor. --- -##### `props`Required +##### `alarmAction`Optional -- *Type:* SqsRecommendedAlarmsProps +```typescript +public readonly alarmAction: IAlarmAction; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm is triggered. --- -#### Methods +##### `insufficientDataAction`Optional -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | +```typescript +public readonly insufficientDataAction: IAlarmAction; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None + +The action to take when an alarm has insufficient data. --- -##### `toString` +##### `okAction`Optional ```typescript -public toString(): string +public readonly okAction: IAlarmAction; ``` -Returns a string representation of this construct. - -#### Static Functions +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | +The action to take when an alarm enters the ok state. --- -##### ~~`isConstruct`~~ +##### `treatMissingData`Optional ```typescript -import { SqsRecommendedAlarms } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -SqsRecommendedAlarms.isConstruct(x: any) +public readonly treatMissingData: TreatMissingData; ``` -Checks if `x` is a construct. +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -###### `x`Required +How to handle missing data for this alarm. -- *Type:* any +--- -Any object. +##### `period`Optional ---- +```typescript +public readonly period: Duration; +``` -#### Properties +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| alarmApproximateAgeOfOldestMessage | SqsApproximateAgeOfOldestMessageAlarm | The approximate age of oldest message alarm. | -| alarmApproximateNumberOfMessagesNotVisible | SqsApproximateNumberOfMessagesNotVisibleAlarm | The approximate number of messages not visible alarm. | -| alarmApproximateNumberOfMessagesVisible | SqsApproximateNumberOfMessagesVisibleAlarm | The approximate number of messages visible alarm. | -| alarmNumberOfMessagesSent | SqsNumberOfMessagesSentAlarm | The number of messages sent alarm. | +The period over which the specified statistic is applied. --- -##### `node`Required +##### `alarmDescription`Optional ```typescript -public readonly node: Node; +public readonly alarmDescription: string; ``` -- *Type:* constructs.Node +- *Type:* string +- *Default:* This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems. -The tree node. +The description of the alarm. --- -##### `alarmApproximateAgeOfOldestMessage`Optional +##### `alarmName`Optional ```typescript -public readonly alarmApproximateAgeOfOldestMessage: SqsApproximateAgeOfOldestMessageAlarm; +public readonly alarmName: string; ``` -- *Type:* SqsApproximateAgeOfOldestMessageAlarm +- *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - CPUUtilization' -The approximate age of oldest message alarm. +The alarm name. --- -##### `alarmApproximateNumberOfMessagesNotVisible`Optional +##### `datapointsToAlarm`Optional ```typescript -public readonly alarmApproximateNumberOfMessagesNotVisible: SqsApproximateNumberOfMessagesNotVisibleAlarm; +public readonly datapointsToAlarm: number; ``` -- *Type:* SqsApproximateNumberOfMessagesNotVisibleAlarm +- *Type:* number +- *Default:* 5 -The approximate number of messages not visible alarm. +The number of data points that must be breaching to trigger the alarm. --- -##### `alarmApproximateNumberOfMessagesVisible`Optional +##### `evaluationPeriods`Optional ```typescript -public readonly alarmApproximateNumberOfMessagesVisible: SqsApproximateNumberOfMessagesVisibleAlarm; +public readonly evaluationPeriods: number; ``` -- *Type:* SqsApproximateNumberOfMessagesVisibleAlarm +- *Type:* number +- *Default:* 5 -The approximate number of messages visible alarm. +The number of periods over which data is compared to the specified threshold. --- -##### `alarmNumberOfMessagesSent`Optional +##### `threshold`Optional ```typescript -public readonly alarmNumberOfMessagesSent: SqsNumberOfMessagesSentAlarm; +public readonly threshold: number; ``` -- *Type:* SqsNumberOfMessagesSentAlarm +- *Type:* number +- *Default:* 90 -The number of messages sent alarm. +The percentage (0-100) value against which the specified statistic is compared. ---- +The service metrics for CPU utilization might exceed 100% utilization. However, +we recommend that you monitor the metric for high CPU utilization to avoid impacting +other services. Set the threshold to about 90-95%. We recommend that you update your +task definitions to reflect actual usage to prevent future issues with other services. +--- -### Topic +### EcsServiceEphemeralStorageUtilizedAlarmProps -An extension of the SNS topic construct that provides helper methods to create recommended alarms. +The properties for the EcsServiceEphemeralStorageUtilizedAlarm construct. -#### Initializers +#### Initializer ```typescript -import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceEphemeralStorageUtilizedAlarmProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' -new Topic(scope: Construct, id: string, props?: TopicProps) +const ecsServiceEphemeralStorageUtilizedAlarmProps: EcsServiceEphemeralStorageUtilizedAlarmProps = { ... } ``` +#### Properties + | **Name** | **Type** | **Description** | | --- | --- | --- | -| scope | constructs.Construct | *No description.* | -| id | string | *No description.* | -| props | aws-cdk-lib.aws_sns.TopicProps | *No description.* | +| service | aws-cdk-lib.aws_ecs.FargateService | The ECS service to monitor. | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| threshold | number | The value in GB against which the specified statistic is compared. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | --- -##### `scope`Required - -- *Type:* constructs.Construct +##### `service`Required ---- +```typescript +public readonly service: FargateService; +``` -##### `id`Required +- *Type:* aws-cdk-lib.aws_ecs.FargateService -- *Type:* string +The ECS service to monitor. --- -##### `props`Optional - -- *Type:* aws-cdk-lib.aws_sns.TopicProps +##### `alarmAction`Optional ---- +```typescript +public readonly alarmAction: IAlarmAction; +``` -#### Methods +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -| **Name** | **Description** | -| --- | --- | -| toString | Returns a string representation of this construct. | -| applyRemovalPolicy | Apply the given removal policy to this resource. | -| addSubscription | Subscribe some endpoint to this topic. | -| addToResourcePolicy | Adds a statement to the IAM resource policy associated with this topic. | -| bindAsNotificationRuleTarget | Represents a notification target That allows SNS topic to associate with this rule target. | -| grantPublish | Grant topic publishing permissions to the given identity. | -| grantSubscribe | Grant topic subscribing permissions to the given identity. | -| metric | Return the given named metric for this Topic. | -| metricNumberOfMessagesPublished | The number of messages published to your Amazon SNS topics. | -| metricNumberOfNotificationsDelivered | The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints. | -| metricNumberOfNotificationsFailed | The number of messages that Amazon SNS failed to deliver. | -| metricNumberOfNotificationsFilteredOut | The number of messages that were rejected by subscription filter policies. | -| metricNumberOfNotificationsFilteredOutInvalidAttributes | The number of messages that were rejected by subscription filter policies because the messages' attributes are invalid. | -| metricNumberOfNotificationsFilteredOutNoMessageAttributes | The number of messages that were rejected by subscription filter policies because the messages have no attributes. | -| metricPublishSize | Metric for the size of messages published through this topic. | -| metricSMSMonthToDateSpentUSD | The charges you have accrued since the start of the current calendar month for sending SMS messages. | -| metricSMSSuccessRate | The rate of successful SMS message deliveries. | -| addLoggingConfig | Adds a delivery status logging configuration to the topic. | -| alarmNumberOfMessagesPublished | Creates an alarm for the NumberOfMessagesPublished metric. | -| alarmNumberOfNotificationsDelivered | Creates an alarm for the NumberOfNotificationsDelivered metric. | -| alarmNumberOfNotificationsFailed | Creates an alarm for the NumberOfNotificationsFailed metric. | -| alarmNumberOfNotificationsFailedToRedriveToDlq | Creates an alarm for the NumberOfNotificationsFailedToRedriveToDlq metric. | -| alarmNumberOfNotificationsFilteredOutInvalidAttributes | Creates an alarm for the NumberOfNotificationsFilteredOutInvalidAttributes metric. | -| alarmNumberOfNotificationsFilteredOutInvalidMessageBody | Creates an alarm for the NumberOfNotificationsFilteredOutInvalidMessageBody metric. | -| alarmNumberOfNotificationsRedrivenToDlq | Creates an alarm for the NumberOfNotificationsRedrivenToDlq metric. | -| applyRecommendedAlarms | Creates recommended alarms for the SNS topic. | +The action to take when an alarm is triggered. --- -##### `toString` +##### `insufficientDataAction`Optional ```typescript -public toString(): string +public readonly insufficientDataAction: IAlarmAction; ``` -Returns a string representation of this construct. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -##### `applyRemovalPolicy` +The action to take when an alarm has insufficient data. + +--- + +##### `okAction`Optional ```typescript -public applyRemovalPolicy(policy: RemovalPolicy): void +public readonly okAction: IAlarmAction; ``` -Apply the given removal policy to this resource. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -The Removal Policy controls what happens to this resource when it stops -being managed by CloudFormation, either because you've removed it from the -CDK application or because you've made a change that requires the resource -to be replaced. +The action to take when an alarm enters the ok state. -The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS -account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). +--- -###### `policy`Required +##### `treatMissingData`Optional -- *Type:* aws-cdk-lib.RemovalPolicy +```typescript +public readonly treatMissingData: TreatMissingData; +``` + +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING + +How to handle missing data for this alarm. --- -##### `addSubscription` +##### `period`Optional ```typescript -public addSubscription(topicSubscription: ITopicSubscription): Subscription +public readonly period: Duration; ``` -Subscribe some endpoint to this topic. - -###### `topicSubscription`Required +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) -- *Type:* aws-cdk-lib.aws_sns.ITopicSubscription +The period over which the specified statistic is applied. --- -##### `addToResourcePolicy` +##### `threshold`Required ```typescript -public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult +public readonly threshold: number; ``` -Adds a statement to the IAM resource policy associated with this topic. - -If this topic was created in this stack (`new Topic`), a topic policy -will be automatically created upon the first call to `addToResourcePolicy`. If -the topic is imported (`Topic.import`), then this is a no-op. +- *Type:* number -###### `statement`Required +The value in GB against which the specified statistic is compared. -- *Type:* aws-cdk-lib.aws_iam.PolicyStatement +Set the threshold to about 90% of the ephemeral storage size. You can adjust this +value based on your acceptable ephemeral storage utilization of the Fargate cluster. +For some systems, a consistently high ephemeral storage utilized might be normal, +while for others, it might lead to failure of the container. --- -##### `bindAsNotificationRuleTarget` +##### `alarmDescription`Optional ```typescript -public bindAsNotificationRuleTarget(_scope: Construct): NotificationRuleTargetConfig +public readonly alarmDescription: string; ``` -Represents a notification target That allows SNS topic to associate with this rule target. - -###### `_scope`Required +- *Type:* string +- *Default:* This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container. -- *Type:* constructs.Construct +The description of the alarm. --- -##### `grantPublish` +##### `alarmName`Optional ```typescript -public grantPublish(grantee: IGrantable): Grant +public readonly alarmName: string; ``` -Grant topic publishing permissions to the given identity. - -###### `grantee`Required +- *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - EphemeralStorageUtilized' -- *Type:* aws-cdk-lib.aws_iam.IGrantable +The alarm name. --- -##### `grantSubscribe` +##### `datapointsToAlarm`Optional ```typescript -public grantSubscribe(grantee: IGrantable): Grant +public readonly datapointsToAlarm: number; ``` -Grant topic subscribing permissions to the given identity. - -###### `grantee`Required +- *Type:* number +- *Default:* 5 -- *Type:* aws-cdk-lib.aws_iam.IGrantable +The number of data points that must be breaching to trigger the alarm. --- -##### `metric` +##### `evaluationPeriods`Optional ```typescript -public metric(metricName: string, props?: MetricOptions): Metric +public readonly evaluationPeriods: number; ``` -Return the given named metric for this Topic. - -###### `metricName`Required +- *Type:* number +- *Default:* 5 -- *Type:* string +The number of periods over which data is compared to the specified threshold. --- -###### `props`Optional - -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +### EcsServiceMemoryUtilizationAlarmProps ---- +The properties for the EcsServiceMemoryUtilizationAlarm construct. -##### `metricNumberOfMessagesPublished` +#### Initializer ```typescript -public metricNumberOfMessagesPublished(props?: MetricOptions): Metric -``` - -The number of messages published to your Amazon SNS topics. +import { EcsServiceMemoryUtilizationAlarmProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Sum over 5 minutes +const ecsServiceMemoryUtilizationAlarmProps: EcsServiceMemoryUtilizationAlarmProps = { ... } +``` -###### `props`Optional +#### Properties -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| service | aws-cdk-lib.aws_ecs.FargateService | The ECS service to monitor. | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | +| threshold | number | The percentage (0-100) value against which the specified statistic is compared. | --- -##### `metricNumberOfNotificationsDelivered` +##### `service`Required ```typescript -public metricNumberOfNotificationsDelivered(props?: MetricOptions): Metric +public readonly service: FargateService; ``` -The number of messages successfully delivered from your Amazon SNS topics to subscribing endpoints. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.aws_ecs.FargateService -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The ECS service to monitor. --- -##### `metricNumberOfNotificationsFailed` +##### `alarmAction`Optional ```typescript -public metricNumberOfNotificationsFailed(props?: MetricOptions): Metric +public readonly alarmAction: IAlarmAction; ``` -The number of messages that Amazon SNS failed to deliver. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The action to take when an alarm is triggered. --- -##### `metricNumberOfNotificationsFilteredOut` +##### `insufficientDataAction`Optional ```typescript -public metricNumberOfNotificationsFilteredOut(props?: MetricOptions): Metric +public readonly insufficientDataAction: IAlarmAction; ``` -The number of messages that were rejected by subscription filter policies. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The action to take when an alarm has insufficient data. --- -##### `metricNumberOfNotificationsFilteredOutInvalidAttributes` +##### `okAction`Optional ```typescript -public metricNumberOfNotificationsFilteredOutInvalidAttributes(props?: MetricOptions): Metric +public readonly okAction: IAlarmAction; ``` -The number of messages that were rejected by subscription filter policies because the messages' attributes are invalid. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The action to take when an alarm enters the ok state. --- -##### `metricNumberOfNotificationsFilteredOutNoMessageAttributes` +##### `treatMissingData`Optional ```typescript -public metricNumberOfNotificationsFilteredOutNoMessageAttributes(props?: MetricOptions): Metric +public readonly treatMissingData: TreatMissingData; ``` -The number of messages that were rejected by subscription filter policies because the messages have no attributes. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +How to handle missing data for this alarm. --- -##### `metricPublishSize` +##### `period`Optional ```typescript -public metricPublishSize(props?: MetricOptions): Metric +public readonly period: Duration; ``` -Metric for the size of messages published through this topic. - -Average over 5 minutes - -###### `props`Optional +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The period over which the specified statistic is applied. --- -##### `metricSMSMonthToDateSpentUSD` +##### `alarmDescription`Optional ```typescript -public metricSMSMonthToDateSpentUSD(props?: MetricOptions): Metric +public readonly alarmDescription: string; ``` -The charges you have accrued since the start of the current calendar month for sending SMS messages. - -Maximum over 5 minutes - -###### `props`Optional +- *Type:* string +- *Default:* This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems. -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The description of the alarm. --- -##### `metricSMSSuccessRate` +##### `alarmName`Optional ```typescript -public metricSMSSuccessRate(props?: MetricOptions): Metric +public readonly alarmName: string; ``` -The rate of successful SMS message deliveries. - -Sum over 5 minutes - -###### `props`Optional +- *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - MemoryUtilization' -- *Type:* aws-cdk-lib.aws_cloudwatch.MetricOptions +The alarm name. --- -##### `addLoggingConfig` +##### `datapointsToAlarm`Optional ```typescript -public addLoggingConfig(config: LoggingConfig): void +public readonly datapointsToAlarm: number; ``` -Adds a delivery status logging configuration to the topic. - -###### `config`Required +- *Type:* number +- *Default:* 5 -- *Type:* aws-cdk-lib.aws_sns.LoggingConfig +The number of data points that must be breaching to trigger the alarm. --- -##### `alarmNumberOfMessagesPublished` +##### `evaluationPeriods`Optional ```typescript -public alarmNumberOfMessagesPublished(props: SnsNumberOfMessagesPublishedAlarmConfig): SnsNumberOfMessagesPublishedAlarm +public readonly evaluationPeriods: number; ``` -Creates an alarm for the NumberOfMessagesPublished metric. - -###### `props`Required +- *Type:* number +- *Default:* 5 -- *Type:* SnsNumberOfMessagesPublishedAlarmConfig +The number of periods over which data is compared to the specified threshold. --- -##### `alarmNumberOfNotificationsDelivered` +##### `threshold`Optional ```typescript -public alarmNumberOfNotificationsDelivered(props: SnsNumberOfNotificationsDeliveredAlarmConfig): SnsNumberOfNotificationsDeliveredAlarm +public readonly threshold: number; ``` -Creates an alarm for the NumberOfNotificationsDelivered metric. +- *Type:* number +- *Default:* 90 -###### `props`Required +The percentage (0-100) value against which the specified statistic is compared. -- *Type:* SnsNumberOfNotificationsDeliveredAlarmConfig +The memory utilization is measured as the total memory in use by the tasks that +belong to the service, divided by the total memory reserved for the tasks that +belong to the service. --- -##### `alarmNumberOfNotificationsFailed` +### EcsServiceRecommendedAlarmsConfig + +Configurations for the recommended alarms for an ECS Service. + +Default actions are overridden by the actions specified in the +individual alarm configurations. + +#### Initializer ```typescript -public alarmNumberOfNotificationsFailed(props: SnsNumberOfNotificationsFailedAlarmConfig): SnsNumberOfNotificationsFailedAlarm -``` +import { EcsServiceRecommendedAlarmsConfig } from '@renovosolutions/cdk-library-cloudwatch-alarms' -Creates an alarm for the NumberOfNotificationsFailed metric. +const ecsServiceRecommendedAlarmsConfig: EcsServiceRecommendedAlarmsConfig = { ... } +``` -###### `props`Required +#### Properties -- *Type:* SnsNumberOfNotificationsFailedAlarmConfig +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| configEphemeralStorageUtilizedAlarm | EcsEphemeralStorageUtilizedAlarmConfig | The configuration for the EphemeralStorageUtilized alarm. | +| configCpuUtilizationAlarm | EcsCpuUtilizationAlarmConfig | The configuration for the CpuUtilization alarm. | +| configMemoryUtilizationAlarm | EcsMemoryUtilizationAlarmConfig | The configuration for the MemoryUtilization alarm. | +| configRunningTaskCountAlarm | EcsRunningTaskCountAlarmConfig | The configuration for the RunningTaskCount alarm. | +| defaultAlarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The default action to take when an alarm is triggered. | +| defaultInsufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The default action to take when an alarm has insufficient data. | +| defaultOkAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The default action to take when an alarm enters the ok state. | +| excludeAlarms | EcsRecommendedAlarmsMetrics[] | Alarm metrics to exclude from the recommended alarms. | +| excludeResources | string[] | The resources to exclude from the recommended alarms. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | --- -##### `alarmNumberOfNotificationsFailedToRedriveToDlq` +##### `configEphemeralStorageUtilizedAlarm`Required ```typescript -public alarmNumberOfNotificationsFailedToRedriveToDlq(props?: SnsNumberOfNotificationsFailedToRedriveToDlqAlarmConfig): SnsNumberOfNotificationsFailedToRedriveToDlqAlarm +public readonly configEphemeralStorageUtilizedAlarm: EcsEphemeralStorageUtilizedAlarmConfig; ``` -Creates an alarm for the NumberOfNotificationsFailedToRedriveToDlq metric. - -###### `props`Optional +- *Type:* EcsEphemeralStorageUtilizedAlarmConfig -- *Type:* SnsNumberOfNotificationsFailedToRedriveToDlqAlarmConfig +The configuration for the EphemeralStorageUtilized alarm. --- -##### `alarmNumberOfNotificationsFilteredOutInvalidAttributes` +##### `configCpuUtilizationAlarm`Optional ```typescript -public alarmNumberOfNotificationsFilteredOutInvalidAttributes(props?: SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmConfig): SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarm +public readonly configCpuUtilizationAlarm: EcsCpuUtilizationAlarmConfig; ``` -Creates an alarm for the NumberOfNotificationsFilteredOutInvalidAttributes metric. - -###### `props`Optional +- *Type:* EcsCpuUtilizationAlarmConfig -- *Type:* SnsNumberOfNotificationsFilteredOutInvalidAttributesAlarmConfig +The configuration for the CpuUtilization alarm. --- -##### `alarmNumberOfNotificationsFilteredOutInvalidMessageBody` +##### `configMemoryUtilizationAlarm`Optional ```typescript -public alarmNumberOfNotificationsFilteredOutInvalidMessageBody(props?: SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmConfig): SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarm +public readonly configMemoryUtilizationAlarm: EcsMemoryUtilizationAlarmConfig; ``` -Creates an alarm for the NumberOfNotificationsFilteredOutInvalidMessageBody metric. - -###### `props`Optional +- *Type:* EcsMemoryUtilizationAlarmConfig -- *Type:* SnsNumberOfNotificationsFilteredOutInvalidMessageBodyAlarmConfig +The configuration for the MemoryUtilization alarm. --- -##### `alarmNumberOfNotificationsRedrivenToDlq` +##### `configRunningTaskCountAlarm`Optional ```typescript -public alarmNumberOfNotificationsRedrivenToDlq(props?: SnsNumberOfNotificationsRedrivenToDlqAlarmConfig): SnsNumberOfNotificationsRedrivenToDlqAlarm +public readonly configRunningTaskCountAlarm: EcsRunningTaskCountAlarmConfig; ``` -Creates an alarm for the NumberOfNotificationsRedrivenToDlq metric. - -###### `props`Optional +- *Type:* EcsRunningTaskCountAlarmConfig -- *Type:* SnsNumberOfNotificationsRedrivenToDlqAlarmConfig +The configuration for the RunningTaskCount alarm. --- -##### `applyRecommendedAlarms` +##### `defaultAlarmAction`Optional ```typescript -public applyRecommendedAlarms(props: SnsRecommendedAlarmsConfig): SnsRecommendedAlarms +public readonly defaultAlarmAction: IAlarmAction; ``` -Creates recommended alarms for the SNS topic. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#SNS) +The default action to take when an alarm is triggered. -###### `props`Required +--- -- *Type:* SnsRecommendedAlarmsConfig +##### `defaultInsufficientDataAction`Optional ---- +```typescript +public readonly defaultInsufficientDataAction: IAlarmAction; +``` -#### Static Functions +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -| **Name** | **Description** | -| --- | --- | -| isConstruct | Checks if `x` is a construct. | -| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | -| isResource | Check whether the given construct is a Resource. | -| fromTopicArn | Import an existing SNS topic provided an ARN. | -| fromTopicAttributes | Import an existing SNS topic provided a topic attributes. | +The default action to take when an alarm has insufficient data. --- -##### ~~`isConstruct`~~ +##### `defaultOkAction`Optional ```typescript -import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Topic.isConstruct(x: any) +public readonly defaultOkAction: IAlarmAction; ``` -Checks if `x` is a construct. - -###### `x`Required - -- *Type:* any +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -Any object. +The default action to take when an alarm enters the ok state. --- -##### `isOwnedResource` +##### `excludeAlarms`Optional ```typescript -import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Topic.isOwnedResource(construct: IConstruct) +public readonly excludeAlarms: EcsRecommendedAlarmsMetrics[]; ``` -Returns true if the construct was created by CDK, and false otherwise. - -###### `construct`Required +- *Type:* EcsRecommendedAlarmsMetrics[] +- *Default:* None -- *Type:* constructs.IConstruct +Alarm metrics to exclude from the recommended alarms. --- -##### `isResource` +##### `excludeResources`Optional ```typescript -import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Topic.isResource(construct: IConstruct) +public readonly excludeResources: string[]; ``` -Check whether the given construct is a Resource. +- *Type:* string[] -###### `construct`Required +The resources to exclude from the recommended alarms. -- *Type:* constructs.IConstruct +Use a resources id to exclude a specific resource. --- -##### `fromTopicArn` +##### `treatMissingData`Optional ```typescript -import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Topic.fromTopicArn(scope: Construct, id: string, topicArn: string) +public readonly treatMissingData: TreatMissingData; ``` -Import an existing SNS topic provided an ARN. - -###### `scope`Required - -- *Type:* constructs.Construct +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -The parent creating construct. +How to handle missing data for this alarm. --- -###### `id`Required +### EcsServiceRecommendedAlarmsProps -- *Type:* string +Properties for the EcsServiceRecommendedAlarms construct. -The construct's name. +#### Initializer ---- +```typescript +import { EcsServiceRecommendedAlarmsProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' -###### `topicArn`Required +const ecsServiceRecommendedAlarmsProps: EcsServiceRecommendedAlarmsProps = { ... } +``` -- *Type:* string +#### Properties -topic ARN (i.e. arn:aws:sns:us-east-2:444455556666:MyTopic). +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| configEphemeralStorageUtilizedAlarm | EcsEphemeralStorageUtilizedAlarmConfig | The configuration for the EphemeralStorageUtilized alarm. | +| configCpuUtilizationAlarm | EcsCpuUtilizationAlarmConfig | The configuration for the CpuUtilization alarm. | +| configMemoryUtilizationAlarm | EcsMemoryUtilizationAlarmConfig | The configuration for the MemoryUtilization alarm. | +| configRunningTaskCountAlarm | EcsRunningTaskCountAlarmConfig | The configuration for the RunningTaskCount alarm. | +| defaultAlarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The default action to take when an alarm is triggered. | +| defaultInsufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The default action to take when an alarm has insufficient data. | +| defaultOkAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The default action to take when an alarm enters the ok state. | +| excludeAlarms | EcsRecommendedAlarmsMetrics[] | Alarm metrics to exclude from the recommended alarms. | +| excludeResources | string[] | The resources to exclude from the recommended alarms. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| service | aws-cdk-lib.aws_ecs.FargateService | The ECS service to monitor. | --- -##### `fromTopicAttributes` - -```typescript -import { Topic } from '@renovosolutions/cdk-library-cloudwatch-alarms' - -Topic.fromTopicAttributes(scope: Construct, id: string, attrs: TopicAttributes) -``` - -Import an existing SNS topic provided a topic attributes. +##### `configEphemeralStorageUtilizedAlarm`Required -###### `scope`Required +```typescript +public readonly configEphemeralStorageUtilizedAlarm: EcsEphemeralStorageUtilizedAlarmConfig; +``` -- *Type:* constructs.Construct +- *Type:* EcsEphemeralStorageUtilizedAlarmConfig -The parent creating construct. +The configuration for the EphemeralStorageUtilized alarm. --- -###### `id`Required +##### `configCpuUtilizationAlarm`Optional -- *Type:* string +```typescript +public readonly configCpuUtilizationAlarm: EcsCpuUtilizationAlarmConfig; +``` -The construct's name. +- *Type:* EcsCpuUtilizationAlarmConfig + +The configuration for the CpuUtilization alarm. --- -###### `attrs`Required +##### `configMemoryUtilizationAlarm`Optional -- *Type:* aws-cdk-lib.aws_sns.TopicAttributes +```typescript +public readonly configMemoryUtilizationAlarm: EcsMemoryUtilizationAlarmConfig; +``` -the attributes of the topic to import. +- *Type:* EcsMemoryUtilizationAlarmConfig + +The configuration for the MemoryUtilization alarm. --- -#### Properties +##### `configRunningTaskCountAlarm`Optional -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | -| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | -| contentBasedDeduplication | boolean | Enables content-based deduplication for FIFO topics. | -| fifo | boolean | Whether this topic is an Amazon SNS FIFO queue. | -| topicArn | string | The ARN of the topic. | -| topicName | string | The name of the topic. | +```typescript +public readonly configRunningTaskCountAlarm: EcsRunningTaskCountAlarmConfig; +``` + +- *Type:* EcsRunningTaskCountAlarmConfig + +The configuration for the RunningTaskCount alarm. --- -##### `node`Required +##### `defaultAlarmAction`Optional ```typescript -public readonly node: Node; +public readonly defaultAlarmAction: IAlarmAction; ``` -- *Type:* constructs.Node +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -The tree node. +The default action to take when an alarm is triggered. --- -##### `env`Required +##### `defaultInsufficientDataAction`Optional ```typescript -public readonly env: ResourceEnvironment; +public readonly defaultInsufficientDataAction: IAlarmAction; ``` -- *Type:* aws-cdk-lib.ResourceEnvironment - -The environment this resource belongs to. +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -For resources that are created and managed by the CDK -(generally, those created by creating new class instances like Role, Bucket, etc.), -this is always the same as the environment of the stack they belong to; -however, for imported resources -(those obtained from static methods like fromRoleArn, fromBucketName, etc.), -that might be different than the stack they were imported into. +The default action to take when an alarm has insufficient data. --- -##### `stack`Required +##### `defaultOkAction`Optional ```typescript -public readonly stack: Stack; +public readonly defaultOkAction: IAlarmAction; ``` -- *Type:* aws-cdk-lib.Stack +- *Type:* aws-cdk-lib.aws_cloudwatch.IAlarmAction +- *Default:* None -The stack in which this resource is defined. +The default action to take when an alarm enters the ok state. --- -##### `contentBasedDeduplication`Required +##### `excludeAlarms`Optional ```typescript -public readonly contentBasedDeduplication: boolean; +public readonly excludeAlarms: EcsRecommendedAlarmsMetrics[]; ``` -- *Type:* boolean +- *Type:* EcsRecommendedAlarmsMetrics[] +- *Default:* None -Enables content-based deduplication for FIFO topics. +Alarm metrics to exclude from the recommended alarms. --- -##### `fifo`Required +##### `excludeResources`Optional ```typescript -public readonly fifo: boolean; +public readonly excludeResources: string[]; ``` -- *Type:* boolean +- *Type:* string[] -Whether this topic is an Amazon SNS FIFO queue. +The resources to exclude from the recommended alarms. -If false, this is a standard topic. +Use a resources id to exclude a specific resource. --- -##### `topicArn`Required +##### `treatMissingData`Optional ```typescript -public readonly topicArn: string; +public readonly treatMissingData: TreatMissingData; ``` -- *Type:* string +- *Type:* aws-cdk-lib.aws_cloudwatch.TreatMissingData +- *Default:* TreatMissingData.MISSING -The ARN of the topic. +How to handle missing data for this alarm. --- -##### `topicName`Required +##### `service`Required ```typescript -public readonly topicName: string; +public readonly service: FargateService; ``` -- *Type:* string +- *Type:* aws-cdk-lib.aws_ecs.FargateService -The name of the topic. +The ECS service to monitor. --- +### EcsServiceRunningTaskCountAlarmProps -## Structs - -### AlarmBaseProps - -The base properties for an alarm where default values are consistent across all alarms. +The properties for the EcsServiceRunningTaskCountAlarm construct. -#### Initializer +#### Initializer ```typescript -import { AlarmBaseProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' +import { EcsServiceRunningTaskCountAlarmProps } from '@renovosolutions/cdk-library-cloudwatch-alarms' -const alarmBaseProps: AlarmBaseProps = { ... } +const ecsServiceRunningTaskCountAlarmProps: EcsServiceRunningTaskCountAlarmProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | -| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | -| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | -| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | -| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| service | aws-cdk-lib.aws_ecs.FargateService | The ECS service to monitor. | +| alarmAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm is triggered. | +| insufficientDataAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm has insufficient data. | +| okAction | aws-cdk-lib.aws_cloudwatch.IAlarmAction | The action to take when an alarm enters the ok state. | +| treatMissingData | aws-cdk-lib.aws_cloudwatch.TreatMissingData | How to handle missing data for this alarm. | +| period | aws-cdk-lib.Duration | The period over which the specified statistic is applied. | +| alarmDescription | string | The description of the alarm. | +| alarmName | string | The alarm name. | +| datapointsToAlarm | number | The number of data points that must be breaching to trigger the alarm. | +| evaluationPeriods | number | The number of periods over which data is compared to the specified threshold. | +| threshold | number | The value against which the specified statistic is compared. | --- -##### `alarmAction`Optional +##### `service`Required + +```typescript +public readonly service: FargateService; +``` + +- *Type:* aws-cdk-lib.aws_ecs.FargateService + +The ECS service to monitor. + +--- + +##### `alarmAction`Optional ```typescript public readonly alarmAction: IAlarmAction; @@ -16908,7 +21060,7 @@ The action to take when an alarm is triggered. --- -##### `insufficientDataAction`Optional +##### `insufficientDataAction`Optional ```typescript public readonly insufficientDataAction: IAlarmAction; @@ -16921,7 +21073,7 @@ The action to take when an alarm has insufficient data. --- -##### `okAction`Optional +##### `okAction`Optional ```typescript public readonly okAction: IAlarmAction; @@ -16934,7 +21086,7 @@ The action to take when an alarm enters the ok state. --- -##### `treatMissingData`Optional +##### `treatMissingData`Optional ```typescript public readonly treatMissingData: TreatMissingData; @@ -16947,6 +21099,87 @@ How to handle missing data for this alarm. --- +##### `period`Optional + +```typescript +public readonly period: Duration; +``` + +- *Type:* aws-cdk-lib.Duration +- *Default:* Duration.minutes(1) + +The period over which the specified statistic is applied. + +--- + +##### `alarmDescription`Optional + +```typescript +public readonly alarmDescription: string; +``` + +- *Type:* string +- *Default:* This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues. + +The description of the alarm. + +--- + +##### `alarmName`Optional + +```typescript +public readonly alarmName: string; +``` + +- *Type:* string +- *Default:* clusterName + ' - ' + serviceName + ' - RunningTaskCount' + +The alarm name. + +--- + +##### `datapointsToAlarm`Optional + +```typescript +public readonly datapointsToAlarm: number; +``` + +- *Type:* number +- *Default:* 5 + +The number of data points that must be breaching to trigger the alarm. + +--- + +##### `evaluationPeriods`Optional + +```typescript +public readonly evaluationPeriods: number; +``` + +- *Type:* number +- *Default:* 5 + +The number of periods over which data is compared to the specified threshold. + +--- + +##### `threshold`Optional + +```typescript +public readonly threshold: number; +``` + +- *Type:* number +- *Default:* 0 + +The value against which the specified statistic is compared. + +You can adjust the threshold based on the minimum running task count of the ECS +service. If the running task count is 0, the Amazon ECS service will be unavailable. + +--- + ### LambdaAlarmBaseConfig #### Initializer @@ -29139,6 +33372,59 @@ The SQS queue for which to create the alarms. ## Classes +### EcsRecommendedAlarmsAspect + +- *Implements:* aws-cdk-lib.IAspect + +Configures the recommended alarms for an ECS service. + +> [https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS) + +#### Initializers + +```typescript +import { EcsRecommendedAlarmsAspect } from '@renovosolutions/cdk-library-cloudwatch-alarms' + +new EcsRecommendedAlarmsAspect(props: EcsServiceRecommendedAlarmsConfig) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| props | EcsServiceRecommendedAlarmsConfig | *No description.* | + +--- + +##### `props`Required + +- *Type:* EcsServiceRecommendedAlarmsConfig + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| visit | All aspects can visit an IConstruct. | + +--- + +##### `visit` + +```typescript +public visit(node: IConstruct): void +``` + +All aspects can visit an IConstruct. + +###### `node`Required + +- *Type:* constructs.IConstruct + +--- + + + + ### LambdaRecommendedAlarmsAspect - *Implements:* aws-cdk-lib.IAspect @@ -29462,6 +33748,49 @@ All aspects can visit an IConstruct. ## Enums +### EcsRecommendedAlarmsMetrics + +The recommended metrics for ECS alarms. + +#### Members + +| **Name** | **Description** | +| --- | --- | +| CPU_UTILIZATION | The percentage of CPU units that is used by the cluster or service. | +| MEMORY_UTILIZATION | The percentage of memory in use by the cluster or service. | +| EPHEMERAL_STORAGE_UTILIZED | The ephemeral storage in GB that is used by the cluster or service. | +| RUNNING_TASK_COUNT | The number of tasks in your services that are in the RUNNING state. | + +--- + +##### `CPU_UTILIZATION` + +The percentage of CPU units that is used by the cluster or service. + +--- + + +##### `MEMORY_UTILIZATION` + +The percentage of memory in use by the cluster or service. + +--- + + +##### `EPHEMERAL_STORAGE_UTILIZED` + +The ephemeral storage in GB that is used by the cluster or service. + +--- + + +##### `RUNNING_TASK_COUNT` + +The number of tasks in your services that are in the RUNNING state. + +--- + + ### LambdaRecommendedAlarmsMetrics The recommended metrics for Lambda alarms. diff --git a/README.md b/README.md index cfeab43..553ea69 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ If its not shown it hasn't been worked on. | SNS |
  • [x] NumberOfMessagesPublished
  • [x] NumberOfNotificationsDelivered
  • [x] NumberOfNotificationsFailed
  • [x] NumberOfNotificationsFilteredOut-InvalidAttributes
  • [x] NumberOfNotificationsFilteredOut-InvalidMessageBody
  • [x] NumberOfNotificationsRedrivenToDlq
  • [x] NumberOfNotificationsFailedToRedriveToDlq
  • [ ] SMSMonthToDateSpentUSD
  • [ ] SMSSuccessRate
| Some alarms require a threshold to be defined. SMS alarms are not implememented. | Lambda |
  • [ ] ClaimedAccountConcurrency
  • [x] Errors
  • [x] Throttles
  • [x] Duration
  • [x] ConcurrentExecutions
| ClaimedAccountConcurrency is account wide and one time so not covered by this library at this time | | RDS | For database & cluster instances
  • [x] CPUUtilization
  • [x] DatabaseConnections
  • [x] FreeableMemory
  • [x] FreeLocalStorage
  • [x] FreeStorageSpace
  • [x] ReadLatency
  • [x] WriteLatency
  • [x] DBLoad
For clusters
  • [x] AuroraVolumeBytesLeftTotal
  • [x] AuroraBinlogReplicaLag
| Some alarms require a `threshold` to be defined. `AuroraVolumeBytesLeftTotal` and `AuroraBinlogReplicaLag` alarms are created only for Aurora MySQL clusters. | +| ECS |
  • [x] CPUUtilization
  • [x] MemoryUtilization
  • [x] EphemeralStorageUtilized
  • [x] RunningTaskCount
| The alarms are applied to `FargateService` constructs only. `EphemeralStorageUtilized` requires a `threshold` to be defined. | ### Aspects diff --git a/src/ecs.ts b/src/ecs.ts new file mode 100644 index 0000000..1b8490c --- /dev/null +++ b/src/ecs.ts @@ -0,0 +1,677 @@ +import { + IAspect, + aws_ecs as ecs, + aws_cloudwatch as cloudwatch, + Duration, +} from 'aws-cdk-lib'; +import { Construct, IConstruct } from 'constructs'; +import { AlarmBaseProps, validateTotalAlarmPeriod } from './common'; + +/** + * The recommended metrics for ECS alarms. + */ +export enum EcsRecommendedAlarmsMetrics { + /** + * The percentage of CPU units that is used by the cluster or service. + */ + CPU_UTILIZATION = 'CPUUtilization', + /** + * The percentage of memory in use by the cluster or service. + */ + MEMORY_UTILIZATION = 'MemoryUtilization', + /** + * The ephemeral storage in GB that is used by the cluster or service. + */ + EPHEMERAL_STORAGE_UTILIZED = 'EphemeralStorageUtilized', + /** + * The number of tasks in your services that are in the RUNNING state. + */ + RUNNING_TASK_COUNT = 'RunningTaskCount', +} + +/** + * The common optional configuration for the alarms. + */ +export interface EcsAlarmBaseConfig extends AlarmBaseProps { + /** + * The period over which the specified statistic is applied. + * + * @default Duration.minutes(1) + */ + readonly period?: Duration; +} + +/** + * The common properties for the ECS service alarms. + */ +export interface EcsServiceAlarmProps { + /** + * The ECS service to monitor. + */ + readonly service: ecs.FargateService; +} + +/** + * Configuration for the CpuUtilization alarm. + */ +export interface EcsCpuUtilizationAlarmConfig extends EcsAlarmBaseConfig { + /** + * The percentage (0-100) value against which the specified statistic is compared. + * The service metrics for CPU utilization might exceed 100% utilization. However, + * we recommend that you monitor the metric for high CPU utilization to avoid impacting + * other services. Set the threshold to about 90-95%. We recommend that you update your + * task definitions to reflect actual usage to prevent future issues with other services. + * + * @default 90 + */ + readonly threshold?: number; + /** + * The number of periods over which data is compared to the specified threshold. + * + * @default 5 + */ + readonly evaluationPeriods?: number; + /** + * The number of data points that must be breaching to trigger the alarm. + * + * @default 5 + */ + readonly datapointsToAlarm?: number; + /** + * The alarm name. + * + * @default - clusterName + ' - ' + serviceName + ' - CPUUtilization' + */ + readonly alarmName?: string; + /** + * The description of the alarm. + * + * @default - This alarm is used to detect high CPU utilization for the ECS service. + * Consistent high CPU utilization can indicate a resource bottleneck or application + * performance problems. + */ + readonly alarmDescription?: string; +} + +/** + * The properties for the EcsServiceCpuUtilizationAlarm construct. + */ +export interface EcsServiceCpuUtilizationAlarmProps extends EcsServiceAlarmProps, EcsCpuUtilizationAlarmConfig {} + +/** + * This alarm is used to detect high CPU utilization for the ECS service. + * + * Consistent high CPU utilization can indicate a resource bottleneck or + * application performance problems. + * + * The alarm is triggered when CPU utilization exceeds % threshold. + */ +export class EcsServiceCpuUtilizationAlarm extends cloudwatch.Alarm { + constructor(scope: IConstruct, id: string, props: EcsServiceCpuUtilizationAlarmProps) { + const alarmName = props.alarmName ?? `${props.service.cluster.clusterName}-${props.service.serviceName} - ${EcsRecommendedAlarmsMetrics.CPU_UTILIZATION}`; + const period = props.period ?? Duration.minutes(1); + const evaluationPeriods = props.evaluationPeriods ?? 5; + const datapointsToAlarm = props.datapointsToAlarm ?? 5; + const threshold = props.threshold ?? 90; + const treatMissingData = props.treatMissingData ?? cloudwatch.TreatMissingData.MISSING; + const alarmDescription = props.alarmDescription ?? 'This alarm is used to detect high CPU utilization for the ECS service.' + + ' Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.'; + + validateTotalAlarmPeriod(period, evaluationPeriods, alarmName); + + super(scope, id, { + alarmName, + metric: props.service.metricCpuUtilization({ + period, + }), + threshold, + evaluationPeriods, + datapointsToAlarm, + treatMissingData, + comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD, + alarmDescription, + }); + + if (props.alarmAction) this.addAlarmAction(props.alarmAction); + if (props.okAction) this.addOkAction(props.okAction); + if (props.insufficientDataAction) this.addInsufficientDataAction(props.insufficientDataAction); + } +}; + +/** + * Configuration for the MemoryUtilization alarm. + */ +export interface EcsMemoryUtilizationAlarmConfig extends EcsAlarmBaseConfig { + /** + * The percentage (0-100) value against which the specified statistic is compared. + * The memory utilization is measured as the total memory in use by the tasks that + * belong to the service, divided by the total memory reserved for the tasks that + * belong to the service. + * + * @default 90 + */ + readonly threshold?: number; + /** + * The number of periods over which data is compared to the specified threshold. + * + * @default 5 + */ + readonly evaluationPeriods?: number; + /** + * The number of data points that must be breaching to trigger the alarm. + * + * @default 5 + */ + readonly datapointsToAlarm?: number; + /** + * The alarm name. + * + * @default - clusterName + ' - ' + serviceName + ' - MemoryUtilization' + */ + readonly alarmName?: string; + /** + * The description of the alarm. + * + * @default - This alarm is used to detect high memory utilization for the ECS service. + * Consistent high memory utilization can indicate a resource bottleneck or application + * performance problems. + */ + readonly alarmDescription?: string; +} + +/** + * The properties for the EcsServiceMemoryUtilizationAlarm construct. + */ +export interface EcsServiceMemoryUtilizationAlarmProps extends EcsServiceAlarmProps, EcsMemoryUtilizationAlarmConfig {} + +/** + * This alarm is used to detect high memory utilization for the ECS service. + * + * Consistent high memory utilization can indicate a resource bottleneck or + * application performance problems. + * + * The alarm is triggered when memory utilization exceeds % threshold. + */ +export class EcsServiceMemoryUtilizationAlarm extends cloudwatch.Alarm { + constructor(scope: IConstruct, id: string, props: EcsServiceMemoryUtilizationAlarmProps) { + const alarmName = props.alarmName ?? `${props.service.cluster.clusterName}-${props.service.serviceName} - ${EcsRecommendedAlarmsMetrics.MEMORY_UTILIZATION}`; + const period = props.period ?? Duration.minutes(1); + const evaluationPeriods = props.evaluationPeriods ?? 5; + const datapointsToAlarm = props.datapointsToAlarm ?? 5; + const threshold = props.threshold ?? 90; + const treatMissingData = props.treatMissingData ?? cloudwatch.TreatMissingData.MISSING; + const alarmDescription = props.alarmDescription ?? 'This alarm is used to detect high memory utilization for the ECS service.' + + ' Consistent high memory utilization can indicate a resource bottleneck or application performance problems.'; + + validateTotalAlarmPeriod(period, evaluationPeriods, alarmName); + + super(scope, id, { + alarmName, + metric: props.service.metricMemoryUtilization({ + period, + }), + threshold, + evaluationPeriods, + datapointsToAlarm, + treatMissingData, + comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD, + alarmDescription, + }); + + if (props.alarmAction) this.addAlarmAction(props.alarmAction); + if (props.okAction) this.addOkAction(props.okAction); + if (props.insufficientDataAction) this.addInsufficientDataAction(props.insufficientDataAction); + } +}; + +/** + * Configuration for the EphemeralStorageUtilized alarm. + */ +export interface EcsEphemeralStorageUtilizedAlarmConfig extends EcsAlarmBaseConfig { + /** + * The value in GB against which the specified statistic is compared. + * Set the threshold to about 90% of the ephemeral storage size. You can adjust this + * value based on your acceptable ephemeral storage utilization of the Fargate cluster. + * For some systems, a consistently high ephemeral storage utilized might be normal, + * while for others, it might lead to failure of the container. + * + */ + readonly threshold: number; + /** + * The number of periods over which data is compared to the specified threshold. + * + * @default 5 + */ + readonly evaluationPeriods?: number; + /** + * The number of data points that must be breaching to trigger the alarm. + * + * @default 5 + */ + readonly datapointsToAlarm?: number; + /** + * The alarm name. + * + * @default - clusterName + ' - ' + serviceName + ' - EphemeralStorageUtilized' + */ + readonly alarmName?: string; + /** + * The description of the alarm. + * + * @default - This alarm is used to detect high ephemeral storage usage for the Fargate cluster. + * Consistent high ephemeral storage utilized can indicate that the disk is full and it might + * lead to failure of the container. + */ + readonly alarmDescription?: string; +} + +/** + * The properties for the EcsServiceEphemeralStorageUtilizedAlarm construct. + */ +export interface EcsServiceEphemeralStorageUtilizedAlarmProps extends EcsServiceAlarmProps, EcsEphemeralStorageUtilizedAlarmConfig {} + +/** + * This alarm is used to detect high ephemeral storage usage for the Fargate cluster. + * + * Consistent high ephemeral storage utilized can indicate that the disk is full and it + * might lead to failure of the container. + * + * The alarm is triggered when the storage utilized (GB) exceeds the threshold. + */ +export class EcsServiceEphemeralStorageUtilizedAlarm extends cloudwatch.Alarm { + constructor(scope: IConstruct, id: string, props: EcsServiceEphemeralStorageUtilizedAlarmProps) { + const alarmName = props.alarmName ?? `${props.service.cluster.clusterName}-${props.service.serviceName} - ${EcsRecommendedAlarmsMetrics.EPHEMERAL_STORAGE_UTILIZED}`; + const period = props.period ?? Duration.minutes(1); + const evaluationPeriods = props.evaluationPeriods ?? 5; + const datapointsToAlarm = props.datapointsToAlarm ?? 5; + const threshold = props.threshold; + const treatMissingData = props.treatMissingData ?? cloudwatch.TreatMissingData.MISSING; + const alarmDescription = props.alarmDescription ?? 'This alarm is used to detect high ephemeral storage usage for the' + + ' Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead' + + ' to failure of the container.'; + + validateTotalAlarmPeriod(period, evaluationPeriods, alarmName); + + super(scope, id, { + alarmName, + metric: new cloudwatch.Metric({ + namespace: 'ECS/ContainerInsights', + metricName: EcsRecommendedAlarmsMetrics.EPHEMERAL_STORAGE_UTILIZED, + dimensionsMap: { + ServiceName: props.service.serviceName, + ClusterName: props.service.cluster.clusterName, + }, + statistic: 'Average', + period, + }), + threshold, + evaluationPeriods, + datapointsToAlarm, + treatMissingData, + comparisonOperator: cloudwatch.ComparisonOperator.GREATER_THAN_THRESHOLD, + alarmDescription, + }); + + if (props.alarmAction) this.addAlarmAction(props.alarmAction); + if (props.okAction) this.addOkAction(props.okAction); + if (props.insufficientDataAction) this.addInsufficientDataAction(props.insufficientDataAction); + } +}; + +/** + * Configuration for the RunningTaskCount alarm. + */ +export interface EcsRunningTaskCountAlarmConfig extends EcsAlarmBaseConfig { + /** + * The value against which the specified statistic is compared. + * You can adjust the threshold based on the minimum running task count of the ECS + * service. If the running task count is 0, the Amazon ECS service will be unavailable. + * + * @default 0 + */ + readonly threshold?: number; + /** + * The number of periods over which data is compared to the specified threshold. + * + * @default 5 + */ + readonly evaluationPeriods?: number; + /** + * The number of data points that must be breaching to trigger the alarm. + * + * @default 5 + */ + readonly datapointsToAlarm?: number; + /** + * The alarm name. + * + * @default - clusterName + ' - ' + serviceName + ' - RunningTaskCount' + */ + readonly alarmName?: string; + /** + * The description of the alarm. + * + * @default - This alarm is used to detect whether the number of running tasks are too low. + * A consistent low running task count can indicate ECS service deployment or performance issues. + */ + readonly alarmDescription?: string; +} + +/** + * The properties for the EcsServiceRunningTaskCountAlarm construct. + */ +export interface EcsServiceRunningTaskCountAlarmProps extends EcsServiceAlarmProps, EcsRunningTaskCountAlarmConfig {} + +/** + * This alarm helps you detect a low running task count of the ECS service. + * + * If the running task count is too low, it can can indicate that the application + * can’t handle the service load and it might lead to performance issues. If there + * is no running task, the Amazon ECS service might be unavailable or there might + * be deployment issues. + * + * The alarm is triggered when the number of running tasks is less than or equal to + * threshold. + */ +export class EcsServiceRunningTaskCountAlarm extends cloudwatch.Alarm { + constructor(scope: IConstruct, id: string, props: EcsServiceRunningTaskCountAlarmProps) { + const alarmName = props.alarmName ?? `${props.service.cluster.clusterName}-${props.service.serviceName} - ${EcsRecommendedAlarmsMetrics.RUNNING_TASK_COUNT}`; + const period = props.period ?? Duration.minutes(1); + const evaluationPeriods = props.evaluationPeriods ?? 5; + const datapointsToAlarm = props.datapointsToAlarm ?? 5; + const threshold = props.threshold ?? 0; + const treatMissingData = props.treatMissingData ?? cloudwatch.TreatMissingData.MISSING; + const alarmDescription = props.alarmDescription ?? 'This alarm is used to detect whether the number of running tasks' + + ' are too low. A consistent low running task count can indicate ECS service deployment or performance issues.'; + + validateTotalAlarmPeriod(period, evaluationPeriods, alarmName); + + super(scope, id, { + alarmName, + metric: new cloudwatch.Metric({ + namespace: 'ECS/ContainerInsights', + metricName: EcsRecommendedAlarmsMetrics.RUNNING_TASK_COUNT, + dimensionsMap: { + ServiceName: props.service.serviceName, + ClusterName: props.service.cluster.clusterName, + }, + statistic: 'Average', + period, + }), + threshold, + evaluationPeriods, + datapointsToAlarm, + treatMissingData, + comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD, + alarmDescription, + }); + + if (props.alarmAction) this.addAlarmAction(props.alarmAction); + if (props.okAction) this.addOkAction(props.okAction); + if (props.insufficientDataAction) this.addInsufficientDataAction(props.insufficientDataAction); + } +}; + +/** + * Configurations for the recommended alarms for an ECS Service. + * + * Default actions are overridden by the actions specified in the + * individual alarm configurations. + */ +export interface EcsServiceRecommendedAlarmsConfig { + /** + * The default action to take when an alarm is triggered. + * + * @default - None + */ + readonly defaultAlarmAction?: cloudwatch.IAlarmAction; + /** + * The default action to take when an alarm enters the ok state. + * + * @default - None + */ + readonly defaultOkAction?: cloudwatch.IAlarmAction; + /** + * The default action to take when an alarm has insufficient data. + * + * @default - None + */ + readonly defaultInsufficientDataAction?: cloudwatch.IAlarmAction; + /** + * How to handle missing data for this alarm. + * + * @default TreatMissingData.MISSING + */ + readonly treatMissingData?: cloudwatch.TreatMissingData; + /** + * Alarm metrics to exclude from the recommended alarms. + * + * @default - None + */ + readonly excludeAlarms?: EcsRecommendedAlarmsMetrics[]; + /** + * The resources to exclude from the recommended alarms. + * + * Use a resources id to exclude a specific resource. + */ + readonly excludeResources?: string[]; + /** + * The configuration for the CpuUtilization alarm. + */ + readonly configCpuUtilizationAlarm?: EcsCpuUtilizationAlarmConfig; + /** + * The configuration for the MemoryUtilization alarm. + */ + readonly configMemoryUtilizationAlarm?: EcsMemoryUtilizationAlarmConfig; + /** + * The configuration for the EphemeralStorageUtilized alarm. + */ + readonly configEphemeralStorageUtilizedAlarm: EcsEphemeralStorageUtilizedAlarmConfig; + /** + * The configuration for the RunningTaskCount alarm. + */ + readonly configRunningTaskCountAlarm?: EcsRunningTaskCountAlarmConfig; +} + +/** + * Properties for the EcsServiceRecommendedAlarms construct. + */ +export interface EcsServiceRecommendedAlarmsProps extends EcsServiceRecommendedAlarmsConfig { + /** + * The ECS service to monitor. + */ + readonly service: ecs.FargateService; +} + +/** + * A construct that creates the recommended alarms for an ECS service. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS + */ +export class EcsServiceRecommendedAlarms extends Construct { + /** + * The CpuUtilization alarm. + */ + public readonly alarmCpuUtilization?: EcsServiceCpuUtilizationAlarm; + + /** + * The MemoryUtilization alarm. + */ + public readonly alarmMemoryUtilization?: EcsServiceMemoryUtilizationAlarm; + + /** + * The EphemeralStorageUtilized alarm. + */ + public readonly alarmEphemeralStorageUtilized?: EcsServiceEphemeralStorageUtilizedAlarm; + + /** + * The RunningTaskCount alarm. + */ + public readonly alarmRunningTaskCount?: EcsServiceRunningTaskCountAlarm; + + constructor(scope: Construct, id: string, props: EcsServiceRecommendedAlarmsProps) { + super(scope, id); + + if (!props.excludeAlarms?.includes(EcsRecommendedAlarmsMetrics.CPU_UTILIZATION)) { + this.alarmCpuUtilization = new EcsServiceCpuUtilizationAlarm(this, `${props.service.node.id}_CpuUtilization`, { + service: props.service, + ...props.configCpuUtilizationAlarm, + }); + + if (props.defaultAlarmAction && !props.configCpuUtilizationAlarm?.alarmAction) { + this.alarmCpuUtilization.addAlarmAction(props.defaultAlarmAction); + } + + if (props.defaultOkAction && !props.configCpuUtilizationAlarm?.okAction) { + this.alarmCpuUtilization.addOkAction(props.defaultOkAction); + } + + if (props.defaultInsufficientDataAction && !props.configCpuUtilizationAlarm?.insufficientDataAction) { + this.alarmCpuUtilization.addInsufficientDataAction(props.defaultInsufficientDataAction); + } + } + + if (!props.excludeAlarms?.includes(EcsRecommendedAlarmsMetrics.MEMORY_UTILIZATION)) { + this.alarmMemoryUtilization = new EcsServiceMemoryUtilizationAlarm(this, `${props.service.node.id}_MemoryUtilization`, { + service: props.service, + ...props.configMemoryUtilizationAlarm, + }); + + if (props.defaultAlarmAction && !props.configMemoryUtilizationAlarm?.alarmAction) { + this.alarmMemoryUtilization.addAlarmAction(props.defaultAlarmAction); + } + + if (props.defaultOkAction && !props.configMemoryUtilizationAlarm?.okAction) { + this.alarmMemoryUtilization.addOkAction(props.defaultOkAction); + } + + if (props.defaultInsufficientDataAction && !props.configMemoryUtilizationAlarm?.insufficientDataAction) { + this.alarmMemoryUtilization.addInsufficientDataAction(props.defaultInsufficientDataAction); + } + } + + if (!props.excludeAlarms?.includes(EcsRecommendedAlarmsMetrics.EPHEMERAL_STORAGE_UTILIZED)) { + this.alarmEphemeralStorageUtilized = new EcsServiceEphemeralStorageUtilizedAlarm(this, `${props.service.node.id}_EphemeralStorageUtilized`, { + service: props.service, + ...props.configEphemeralStorageUtilizedAlarm, + }); + + if (props.defaultAlarmAction && !props.configEphemeralStorageUtilizedAlarm.alarmAction) { + this.alarmEphemeralStorageUtilized.addAlarmAction(props.defaultAlarmAction); + } + + if (props.defaultOkAction && !props.configEphemeralStorageUtilizedAlarm.okAction) { + this.alarmEphemeralStorageUtilized.addOkAction(props.defaultOkAction); + } + + if (props.defaultInsufficientDataAction && !props.configEphemeralStorageUtilizedAlarm.insufficientDataAction) { + this.alarmEphemeralStorageUtilized.addInsufficientDataAction(props.defaultInsufficientDataAction); + } + } + + if (!props.excludeAlarms?.includes(EcsRecommendedAlarmsMetrics.RUNNING_TASK_COUNT)) { + this.alarmRunningTaskCount = new EcsServiceRunningTaskCountAlarm(this, `${props.service.node.id}_RunningTaskCount`, { + service: props.service, + ...props.configRunningTaskCountAlarm, + }); + + if (props.defaultAlarmAction && !props.configRunningTaskCountAlarm?.alarmAction) { + this.alarmRunningTaskCount.addAlarmAction(props.defaultAlarmAction); + } + + if (props.defaultOkAction && !props.configRunningTaskCountAlarm?.okAction) { + this.alarmRunningTaskCount.addOkAction(props.defaultOkAction); + } + + if (props.defaultInsufficientDataAction && !props.configRunningTaskCountAlarm?.insufficientDataAction) { + this.alarmRunningTaskCount.addInsufficientDataAction(props.defaultInsufficientDataAction); + } + } + } +} + +/** + * An extension for the FargateService construct that provides methods + * to create recommended alarms. + */ +export class FargateService extends ecs.FargateService { + constructor(scope: Construct, id: string, props: ecs.FargateServiceProps) { + super(scope, id, props); + } + + /** + * Creates an alarm that monitors the CPU utilization for the Fargate service. + */ + public alarmCpuUtilization(props?: EcsCpuUtilizationAlarmConfig): EcsServiceCpuUtilizationAlarm { + return new EcsServiceCpuUtilizationAlarm(this, 'CpuUtilizationAlarm', { + service: this, + ...props, + }); + } + + /** + * Creates an alarm that monitors the memory utilization for the Fargate service. + */ + public alarmMemoryUtilization(props?: EcsMemoryUtilizationAlarmConfig): EcsServiceMemoryUtilizationAlarm { + return new EcsServiceMemoryUtilizationAlarm(this, 'MemoryUtilizationAlarm', { + service: this, + ...props, + }); + } + + /** + * Creates an alarm that monitors the ephemeral storage utilized for the Fargate service. + */ + public alarmEphemeralStorageUtilized(props: EcsEphemeralStorageUtilizedAlarmConfig): EcsServiceEphemeralStorageUtilizedAlarm { + return new EcsServiceEphemeralStorageUtilizedAlarm(this, 'EphemeralStorageUtilizedAlarm', { + service: this, + ...props, + }); + } + + /** + * Creates an alarm that monitors the number of task running. + */ + public alarmRunningTaskCount(props?: EcsRunningTaskCountAlarmConfig): EcsServiceRunningTaskCountAlarm { + return new EcsServiceRunningTaskCountAlarm(this, 'RunningTaskCountAlarm', { + service: this, + ...props, + }); + } + + /** + * Creates the recommended alarms for the ECS service. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS + */ + public applyRecommendedAlarms(props: EcsServiceRecommendedAlarmsConfig): EcsServiceRecommendedAlarms { + return new EcsServiceRecommendedAlarms(this, 'EcsServiceRecommendedAlarms', { + service: this, + ...props, + }); + } +} + +/** + * Configures the recommended alarms for an ECS service. + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ECS + */ +export class EcsRecommendedAlarmsAspect implements IAspect { + constructor(private readonly props: EcsServiceRecommendedAlarmsConfig) {} + + public visit(node: IConstruct): void { + if (node instanceof ecs.FargateService) { + if (this.props.excludeResources && this.props.excludeResources.includes(node.node.id)) { + return; + } else { + const service = node as ecs.FargateService; + + new EcsServiceRecommendedAlarms(service, 'EcsServiceRecommendedAlarmsFromAspect', { + service, + ...this.props, + }); + } + } + } +} diff --git a/src/index.ts b/src/index.ts index d93c92b..f2e3b08 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export * from './common'; +export * from './ecs'; export * from './lambda'; export * from './rds'; export * from './s3'; diff --git a/test/__snapshots__/ecs.test.ts.snap b/test/__snapshots__/ecs.test.ts.snap new file mode 100644 index 0000000..5aa8ccc --- /dev/null +++ b/test/__snapshots__/ecs.test.ts.snap @@ -0,0 +1,8826 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EcsServiceSnapshot 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "ServiceD69D759B": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "ServiceSecurityGroupC96ED6A7", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceCpuUtilization2BC2992E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - CPUUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceEphemeralStorageUtilizedBA89A12E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceMemoryUtilizationC5E8B967": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceRunningTaskCount97F96CFB": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceSecurityGroupC96ED6A7": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "ServiceTaskCountTarget23E25614": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`EcsServiceSnapshotDefaultActionsInUse 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "ServiceD69D759B": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "ServiceSecurityGroupC96ED6A7", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "ServiceSecurityGroupC96ED6A7": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "ServiceTaskCountTarget23E25614": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "TopicBFC7AF6E": Object { + "Type": "AWS::SNS::Topic", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + "ecsServiceAlarmsServiceCpuUtilization3A3354F9": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - CPUUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ecsServiceAlarmsServiceEphemeralStorageUtilizedAD3FAB25": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ecsServiceAlarmsServiceMemoryUtilization226342D8": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ecsServiceAlarmsServiceRunningTaskCount8874E89D": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`EcsServiceSnapshotWithExclusion 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "ServiceD69D759B": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "ServiceSecurityGroupC96ED6A7", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceEphemeralStorageUtilizedBA89A12E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceMemoryUtilizationC5E8B967": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceRunningTaskCount97F96CFB": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceSecurityGroupC96ED6A7": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "ServiceTaskCountTarget23E25614": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`SnapshotForEcsServiceConstruct 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "ServiceD69D759B": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "ServiceSecurityGroupC96ED6A7", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "ServiceEcsServiceRecommendedAlarmsServiceCpuUtilizationDAF02661": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - CPUUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsServiceEphemeralStorageUtilizedA0ECC9C2": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsServiceMemoryUtilizationC1D94DB2": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsServiceRunningTaskCount172FD909": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceSecurityGroupC96ED6A7": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "ServiceTaskCountTarget23E25614": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`alarms can be applied individually to services using extended construct 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "ServiceCpuUtilizationAlarmA918C853": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - CPUUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceD69D759B": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "ServiceSecurityGroupC96ED6A7", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "ServiceEphemeralStorageUtilizedAlarm43DA915F": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceMemoryUtilizationAlarmA4074DDB": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceRunningTaskCountAlarm5DEE6328": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceSecurityGroupC96ED6A7": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "ServiceTaskCountTarget23E25614": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`default alarm actions are overridden when individual alarm actions are provided in configuration 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "LambdaD247545B": Object { + "DependsOn": Array [ + "LambdaServiceRoleA8ED4D3B", + ], + "Properties": Object { + "Code": Object { + "ZipFile": "exports.handler = async (event) => { console.log(event); }", + }, + "Handler": "index.handler", + "Role": Object { + "Fn::GetAtt": Array [ + "LambdaServiceRoleA8ED4D3B", + "Arn", + ], + }, + "Runtime": "nodejs20.x", + }, + "Type": "AWS::Lambda::Function", + }, + "LambdaServiceCpuUtilizationAlarmPermissionE8191EF4": Object { + "Properties": Object { + "Action": "lambda:InvokeFunction", + "FunctionName": Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + "Principal": "lambda.alarms.cloudwatch.amazonaws.com", + "SourceAccount": "123456789012", + "SourceArn": Object { + "Fn::GetAtt": Array [ + "ecsServiceAlarmsServiceCpuUtilization3A3354F9", + "Arn", + ], + }, + }, + "Type": "AWS::Lambda::Permission", + }, + "LambdaServiceEphemeralStorageUtilizedAlarmPermissionDE174648": Object { + "Properties": Object { + "Action": "lambda:InvokeFunction", + "FunctionName": Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + "Principal": "lambda.alarms.cloudwatch.amazonaws.com", + "SourceAccount": "123456789012", + "SourceArn": Object { + "Fn::GetAtt": Array [ + "ecsServiceAlarmsServiceEphemeralStorageUtilizedAD3FAB25", + "Arn", + ], + }, + }, + "Type": "AWS::Lambda::Permission", + }, + "LambdaServiceMemoryUtilizationAlarmPermissionEBFF25D3": Object { + "Properties": Object { + "Action": "lambda:InvokeFunction", + "FunctionName": Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + "Principal": "lambda.alarms.cloudwatch.amazonaws.com", + "SourceAccount": "123456789012", + "SourceArn": Object { + "Fn::GetAtt": Array [ + "ecsServiceAlarmsServiceMemoryUtilization226342D8", + "Arn", + ], + }, + }, + "Type": "AWS::Lambda::Permission", + }, + "LambdaServiceRoleA8ED4D3B": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "lambda.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + "ManagedPolicyArns": Array [ + Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + ], + ], + }, + ], + }, + "Type": "AWS::IAM::Role", + }, + "LambdaServiceRunningTaskCountAlarmPermissionE7F936AC": Object { + "Properties": Object { + "Action": "lambda:InvokeFunction", + "FunctionName": Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + "Principal": "lambda.alarms.cloudwatch.amazonaws.com", + "SourceAccount": "123456789012", + "SourceArn": Object { + "Fn::GetAtt": Array [ + "ecsServiceAlarmsServiceRunningTaskCount8874E89D", + "Arn", + ], + }, + }, + "Type": "AWS::Lambda::Permission", + }, + "ServiceD69D759B": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "ServiceSecurityGroupC96ED6A7", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "ServiceSecurityGroupC96ED6A7": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "ServiceTaskCountTarget23E25614": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "TopicBFC7AF6E": Object { + "Type": "AWS::SNS::Topic", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + "ecsServiceAlarmsServiceCpuUtilization3A3354F9": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "AlarmDescription": "This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - CPUUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "OKActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ecsServiceAlarmsServiceEphemeralStorageUtilizedAD3FAB25": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "OKActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 5, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ecsServiceAlarmsServiceMemoryUtilization226342D8": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "OKActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 10, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ecsServiceAlarmsServiceRunningTaskCount8874E89D": Object { + "Properties": Object { + "AlarmActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "InsufficientDataActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "OKActions": Array [ + Object { + "Fn::GetAtt": Array [ + "LambdaD247545B", + "Arn", + ], + }, + ], + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`optional alarm configurations can be overwritten 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "Service1EcsServiceRecommendedAlarmsFromAspectService1CpuUtilization670F257D": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "Custom alarm description", + "AlarmName": "CustomCpuUtilizationAlarm", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 25, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service1Service6EBC868E", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 25, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 300, + "Statistic": "Average", + "Threshold": 10, + "TreatMissingData": "ignore", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service1EcsServiceRecommendedAlarmsFromAspectService1EphemeralStorageUtilizedBADF9497": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "Custom alarm description", + "AlarmName": "CustomEphemeralStorageUtilizedAlarm", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 25, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service1Service6EBC868E", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 25, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 300, + "Statistic": "Average", + "Threshold": 5, + "TreatMissingData": "ignore", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service1EcsServiceRecommendedAlarmsFromAspectService1MemoryUtilizationA61D7CA0": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "Custom alarm description", + "AlarmName": "CustomMemoryUtilizationAlarm", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 25, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service1Service6EBC868E", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 25, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 300, + "Statistic": "Average", + "Threshold": 10, + "TreatMissingData": "ignore", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service1EcsServiceRecommendedAlarmsFromAspectService1RunningTaskCountCD775590": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "AlarmDescription": "Custom alarm description", + "AlarmName": "CustomRunningTaskCountAlarm", + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 25, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service1Service6EBC868E", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 25, + "InsufficientDataActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "OKActions": Array [ + Object { + "Ref": "TopicBFC7AF6E", + }, + ], + "Period": 300, + "Statistic": "Average", + "Threshold": 20, + "TreatMissingData": "ignore", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service1SecurityGroup6439F779": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service1/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "Service1Service6EBC868E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "Service1SecurityGroup6439F779", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "Service1TaskCountTarget48418001": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "Service1Service6EBC868E", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "TopicBFC7AF6E": Object { + "Type": "AWS::SNS::Topic", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`stack should contain service recommended alarms if recommended alarms aspect is applied with no exclusions 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "ServiceD69D759B": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "ServiceSecurityGroupC96ED6A7", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceCpuUtilization2BC2992E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - CPUUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceEphemeralStorageUtilizedBA89A12E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceMemoryUtilizationC5E8B967": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceEcsServiceRecommendedAlarmsFromAspectServiceRunningTaskCount97F96CFB": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "ServiceSecurityGroupC96ED6A7": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "ServiceTaskCountTarget23E25614": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "ServiceD69D759B", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; + +exports[`when an resource is excluded from the aspect config it should not have alarms 1`] = ` +Object { + "Parameters": Object { + "BootstrapVersion": Object { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": Object { + "ClusterEB0386A7": Object { + "Properties": Object { + "ClusterName": "TestCluster", + "ClusterSettings": Array [ + Object { + "Name": "containerInsights", + "Value": "enabled", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, + "Service1SecurityGroup6439F779": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service1/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "Service1Service6EBC868E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "Service1SecurityGroup6439F779", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "Service1TaskCountTarget48418001": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "Service1Service6EBC868E", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "Service2EcsServiceRecommendedAlarmsFromAspectService2CpuUtilization22D8B29C": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high CPU utilization for the ECS service. Consistent high CPU utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + " - CPUUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "CPUUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service2EcsServiceRecommendedAlarmsFromAspectService2EphemeralStorageUtilized2FF80D22": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high ephemeral storage usage for the Fargate cluster. Consistent high ephemeral storage utilized can indicate that the disk is full and it might lead to failure of the container.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + " - EphemeralStorageUtilized", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "EphemeralStorageUtilized", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service2EcsServiceRecommendedAlarmsFromAspectService2MemoryUtilizationAB6EDC31": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect high memory utilization for the ECS service. Consistent high memory utilization can indicate a resource bottleneck or application performance problems.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + " - MemoryUtilization", + ], + ], + }, + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "MemoryUtilization", + "Namespace": "AWS/ECS", + "Period": 60, + "Statistic": "Average", + "Threshold": 90, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service2EcsServiceRecommendedAlarmsFromAspectService2RunningTaskCountEAFCD850": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "AlarmDescription": "This alarm is used to detect whether the number of running tasks are too low. A consistent low running task count can indicate ECS service deployment or performance issues.", + "AlarmName": Object { + "Fn::Join": Array [ + "", + Array [ + Object { + "Ref": "ClusterEB0386A7", + }, + "-", + Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + " - RunningTaskCount", + ], + ], + }, + "ComparisonOperator": "LessThanOrEqualToThreshold", + "DatapointsToAlarm": 5, + "Dimensions": Array [ + Object { + "Name": "ClusterName", + "Value": Object { + "Ref": "ClusterEB0386A7", + }, + }, + Object { + "Name": "ServiceName", + "Value": Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + }, + ], + "EvaluationPeriods": 5, + "MetricName": "RunningTaskCount", + "Namespace": "ECS/ContainerInsights", + "Period": 60, + "Statistic": "Average", + "Threshold": 0, + "TreatMissingData": "missing", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "Service2SecurityGroup0BEEFA6E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "GroupDescription": "TestStack/Service2/SecurityGroup", + "SecurityGroupEgress": Array [ + Object { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "Service2ServiceEE0EB41F": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "Cluster": Object { + "Ref": "ClusterEB0386A7", + }, + "DeploymentConfiguration": Object { + "Alarms": Object { + "AlarmNames": Array [], + "Enable": false, + "Rollback": false, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50, + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": Object { + "AwsvpcConfiguration": Object { + "AssignPublicIp": "DISABLED", + "SecurityGroups": Array [ + Object { + "Fn::GetAtt": Array [ + "Service2SecurityGroup0BEEFA6E", + "GroupId", + ], + }, + ], + "Subnets": Array [ + Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + ], + }, + }, + "TaskDefinition": Object { + "Ref": "TaskDef54694570", + }, + }, + "Type": "AWS::ECS::Service", + }, + "Service2TaskCountTarget9745568E": Object { + "DependsOn": Array [ + "TaskDefTaskRole1EDB4A67", + ], + "Properties": Object { + "MaxCapacity": 10, + "MinCapacity": 1, + "ResourceId": Object { + "Fn::Join": Array [ + "", + Array [ + "service/", + Object { + "Ref": "ClusterEB0386A7", + }, + "/", + Object { + "Fn::GetAtt": Array [ + "Service2ServiceEE0EB41F", + "Name", + ], + }, + ], + ], + }, + "RoleARN": Object { + "Fn::Join": Array [ + "", + Array [ + "arn:", + Object { + "Ref": "AWS::Partition", + }, + ":iam::123456789012:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "TaskDef54694570": Object { + "Properties": Object { + "ContainerDefinitions": Array [ + Object { + "Cpu": 256, + "Essential": true, + "Image": "amazon/amazon-ecs-sample", + "Memory": 512, + "Name": "Container", + }, + ], + "Cpu": "256", + "Family": "TestStackTaskDefA6238255", + "Memory": "512", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": Array [ + "FARGATE", + ], + "TaskRoleArn": Object { + "Fn::GetAtt": Array [ + "TaskDefTaskRole1EDB4A67", + "Arn", + ], + }, + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "TaskDefTaskRole1EDB4A67": Object { + "Properties": Object { + "AssumeRolePolicyDocument": Object { + "Statement": Array [ + Object { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": Object { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + }, + "Type": "AWS::IAM::Role", + }, + "VPCB9E5F0B4": Object { + "Properties": Object { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::VPC", + }, + "VPCIGWB7E252D3": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC", + }, + ], + }, + "Type": "AWS::EC2::InternetGateway", + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet1NATGatewayE0556630", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet1RouteTableBE8A6027": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet1Subnet8BCA10E0": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.96.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet2NATGateway3C070193", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet2RouteTable0A19E10E": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.128.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPrivateSubnet3DefaultRoute27F311AE": Object { + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": Object { + "Ref": "VPCPublicSubnet3NATGatewayD3048F5C", + }, + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPrivateSubnet3RouteTable192186F8": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPrivateSubnet3RouteTableAssociationC28D144E": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPrivateSubnet3RouteTable192186F8", + }, + "SubnetId": Object { + "Ref": "VPCPrivateSubnet3Subnet3EDCD457", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPrivateSubnet3Subnet3EDCD457": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.160.0/19", + "MapPublicIpOnLaunch": false, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Private", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Private", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PrivateSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet1DefaultRoute91CEF279": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet1EIP6AD938E8": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet1NATGatewayE0556630": Object { + "DependsOn": Array [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet1SubnetB4246D30", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet1RouteTableFEE4B781": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet1SubnetB4246D30": Object { + "Properties": Object { + "AvailabilityZone": "dummy1a", + "CidrBlock": "10.0.0.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet1", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet2EIP4947BC00": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet2NATGateway3C070193": Object { + "DependsOn": Array [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet2RouteTable6F1A15F1": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet2Subnet74179F39", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet2Subnet74179F39": Object { + "Properties": Object { + "AvailabilityZone": "dummy1b", + "CidrBlock": "10.0.32.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet2", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCPublicSubnet3DefaultRouteA0D29D46": Object { + "DependsOn": Array [ + "VPCVPCGW99B986DC", + ], + "Properties": Object { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + }, + "Type": "AWS::EC2::Route", + }, + "VPCPublicSubnet3EIPAD4BC883": Object { + "Properties": Object { + "Domain": "vpc", + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::EIP", + }, + "VPCPublicSubnet3NATGatewayD3048F5C": Object { + "DependsOn": Array [ + "VPCPublicSubnet3DefaultRouteA0D29D46", + "VPCPublicSubnet3RouteTableAssociation427FE0C6", + ], + "Properties": Object { + "AllocationId": Object { + "Fn::GetAtt": Array [ + "VPCPublicSubnet3EIPAD4BC883", + "AllocationId", + ], + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + }, + "Type": "AWS::EC2::NatGateway", + }, + "VPCPublicSubnet3RouteTable98AE0E14": Object { + "Properties": Object { + "Tags": Array [ + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::RouteTable", + }, + "VPCPublicSubnet3RouteTableAssociation427FE0C6": Object { + "Properties": Object { + "RouteTableId": Object { + "Ref": "VPCPublicSubnet3RouteTable98AE0E14", + }, + "SubnetId": Object { + "Ref": "VPCPublicSubnet3Subnet631C5E25", + }, + }, + "Type": "AWS::EC2::SubnetRouteTableAssociation", + }, + "VPCPublicSubnet3Subnet631C5E25": Object { + "Properties": Object { + "AvailabilityZone": "dummy1c", + "CidrBlock": "10.0.64.0/19", + "MapPublicIpOnLaunch": true, + "Tags": Array [ + Object { + "Key": "aws-cdk:subnet-name", + "Value": "Public", + }, + Object { + "Key": "aws-cdk:subnet-type", + "Value": "Public", + }, + Object { + "Key": "Name", + "Value": "TestStack/VPC/PublicSubnet3", + }, + ], + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::Subnet", + }, + "VPCVPCGW99B986DC": Object { + "Properties": Object { + "InternetGatewayId": Object { + "Ref": "VPCIGWB7E252D3", + }, + "VpcId": Object { + "Ref": "VPCB9E5F0B4", + }, + }, + "Type": "AWS::EC2::VPCGatewayAttachment", + }, + }, + "Rules": Object { + "CheckBootstrapVersion": Object { + "Assertions": Array [ + Object { + "Assert": Object { + "Fn::Not": Array [ + Object { + "Fn::Contains": Array [ + Array [ + "1", + "2", + "3", + "4", + "5", + ], + Object { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; diff --git a/test/ecs.test.ts b/test/ecs.test.ts new file mode 100644 index 0000000..ff444ad --- /dev/null +++ b/test/ecs.test.ts @@ -0,0 +1,485 @@ +import { + aws_cloudwatch as cloudwatch, + aws_cloudwatch_actions as cloudwatch_actions, + aws_ec2 as ec2, + aws_ecs as ecs, + aws_lambda as lambda, + aws_sns as sns, + Aspects, + App, + Duration, + Stack, + StackProps, +} from 'aws-cdk-lib'; +import { + Match, + Template, +} from 'aws-cdk-lib/assertions'; +import * as ecsAlarms from '../src/ecs'; + +class EcsFargateServiceStack extends Stack { + + public readonly cluster: ecs.Cluster; + + public readonly service: ecsAlarms.FargateService; + + public readonly taskDefinition: ecs.FargateTaskDefinition; + + constructor(scope: App, id: string, props?: StackProps) { + super(scope, id, props); + + this.cluster = new ecs.Cluster(this, 'Cluster', { + vpc: new ec2.Vpc(this, 'VPC'), + containerInsights: true, + clusterName: 'TestCluster', + }); + + this.taskDefinition = new ecs.FargateTaskDefinition(this, 'TaskDef', { + memoryLimitMiB: 512, + cpu: 256, + }); + + this.taskDefinition.addContainer('Container', { + image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), + memoryLimitMiB: 512, + cpu: 256, + }); + + this.service = new ecsAlarms.FargateService(this, 'Service', { + cluster: this.cluster, + taskDefinition: this.taskDefinition, + }); + + this.service.autoScaleTaskCount({ + minCapacity: 1, + maxCapacity: 10, + }); + } +} + +test('EcsServiceSnapshot', () => { + const app = new App(); + const appAspects = Aspects.of(app); + + appAspects.add( + new ecsAlarms.EcsRecommendedAlarmsAspect({ + configEphemeralStorageUtilizedAlarm: { + threshold: 90, + }, + }), + ); + + const stack = new EcsFargateServiceStack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); +}); + +test('EcsServiceSnapshotWithExclusion', () => { + const app = new App(); + const appAspects = Aspects.of(app); + + appAspects.add( + new ecsAlarms.EcsRecommendedAlarmsAspect({ + excludeAlarms: [ecsAlarms.EcsRecommendedAlarmsMetrics.CPU_UTILIZATION], + configEphemeralStorageUtilizedAlarm: { + threshold: 90, + }, + }), + ); + + const stack = new EcsFargateServiceStack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); +}); + +test('SnapshotForEcsServiceConstruct', () => { + const app = new App(); + const stack = new EcsFargateServiceStack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + stack.service.applyRecommendedAlarms({ + configEphemeralStorageUtilizedAlarm: { + threshold: 90, + }, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); +}); + +test('EcsServiceSnapshotDefaultActionsInUse', () => { + const app = new App(); + const stack = new EcsFargateServiceStack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + const alarmTopic = new sns.Topic(stack, 'Topic'); + + new ecsAlarms.EcsServiceRecommendedAlarms(stack, 'ecsServiceAlarms', { + service: stack.service, + defaultAlarmAction: new cloudwatch_actions.SnsAction(alarmTopic), + defaultOkAction: new cloudwatch_actions.SnsAction(alarmTopic), + defaultInsufficientDataAction: new cloudwatch_actions.SnsAction(alarmTopic), + configEphemeralStorageUtilizedAlarm: { + threshold: 90, + }, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); +}); + +test('stack should contain service recommended alarms if recommended alarms aspect is applied with no exclusions', () => { + const app = new App(); + const appAspects = Aspects.of(app); + + appAspects.add( + new ecsAlarms.EcsRecommendedAlarmsAspect({ + configEphemeralStorageUtilizedAlarm: { + threshold: 90, + }, + }), + ); + + const stack = new EcsFargateServiceStack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); + + const numOfMetrics = Object.keys(ecsAlarms.EcsRecommendedAlarmsMetrics).length; + + template.resourceCountIs('AWS::CloudWatch::Alarm', numOfMetrics); + + const resources = template.findResources('AWS::CloudWatch::Alarm'); + + Object.keys(ecsAlarms.EcsRecommendedAlarmsMetrics).forEach(metricKey => { + const alarms = Object.keys(resources).filter(resourceName => { + const resource = resources[resourceName]; + const resourceProperties = resource.Properties; + const metricName = ecsAlarms.EcsRecommendedAlarmsMetrics[metricKey as keyof typeof ecsAlarms.EcsRecommendedAlarmsMetrics]; + + return resourceProperties.MetricName === metricName; + }); + + expect(alarms.length).toEqual(1); + }); +}); + +test('alarms can be applied individually to services using extended construct', () => { + const app = new App(); + const stack = new EcsFargateServiceStack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + stack.service.alarmCpuUtilization(); + stack.service.alarmMemoryUtilization(); + stack.service.alarmEphemeralStorageUtilized({ threshold: 90 }); + stack.service.alarmRunningTaskCount(); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); + + const numOfMetrics = Object.keys(ecsAlarms.EcsRecommendedAlarmsMetrics).length; + + template.resourceCountIs('AWS::CloudWatch::Alarm', numOfMetrics); + + const resources = template.findResources('AWS::CloudWatch::Alarm'); + + Object.keys(ecsAlarms.EcsRecommendedAlarmsMetrics).forEach(metricKey => { + const alarms = Object.keys(resources).filter(resourceName => { + const resource = resources[resourceName]; + const resourceProperties = resource.Properties; + const metricName = ecsAlarms.EcsRecommendedAlarmsMetrics[metricKey as keyof typeof ecsAlarms.EcsRecommendedAlarmsMetrics]; + + return resourceProperties.MetricName === metricName; + }); + + expect(alarms.length).toBe(1); + }); +}); + +test('when an resource is excluded from the aspect config it should not have alarms', () => { + const app = new App(); + const stack = new Stack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + const appAspects = Aspects.of(app); + + appAspects.add( + new ecsAlarms.EcsRecommendedAlarmsAspect({ + excludeResources: ['Service1'], + configEphemeralStorageUtilizedAlarm: { + threshold: 90, + }, + }), + ); + + const cluster = new ecs.Cluster(stack, 'Cluster', { + vpc: new ec2.Vpc(stack, 'VPC'), + containerInsights: true, + clusterName: 'TestCluster', + }); + + const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', { + memoryLimitMiB: 512, + cpu: 256, + }); + + taskDefinition.addContainer('Container', { + image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), + memoryLimitMiB: 512, + cpu: 256, + }); + + const service1 = new ecsAlarms.FargateService(stack, 'Service1', { + cluster, + taskDefinition, + }); + + service1.autoScaleTaskCount({ + minCapacity: 1, + maxCapacity: 10, + }); + + const service2 = new ecsAlarms.FargateService(stack, 'Service2', { + cluster, + taskDefinition, + }); + + service2.autoScaleTaskCount({ + minCapacity: 1, + maxCapacity: 10, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); + + const numOfMetrics = Object.keys(ecsAlarms.EcsRecommendedAlarmsMetrics).length; + + const resources = template.findResources('AWS::CloudWatch::Alarm'); + expect(Object.keys(resources).length).toEqual(numOfMetrics); + + ['Service1', 'Service2'].forEach(serviceName => { + Object.keys(ecsAlarms.EcsRecommendedAlarmsMetrics).forEach(metricKey => { + const alarms = Object.keys(resources).filter(resourceName => { + const resource = resources[resourceName]; + const resourceProperties = resource.Properties; + const metricName = ecsAlarms.EcsRecommendedAlarmsMetrics[metricKey as keyof typeof ecsAlarms.EcsRecommendedAlarmsMetrics]; + + return resourceName.startsWith(serviceName) && resourceProperties.MetricName === metricName; + }); + if (serviceName === 'Service1') { + expect(alarms.length).toEqual(0); + } else { + expect(alarms.length).toEqual(1); + } + }); + }); +}); + +test('default alarm actions are overridden when individual alarm actions are provided in configuration', () => { + const app = new App({ + context: { + '@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction': true, + }, + }); + const stack = new EcsFargateServiceStack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + const topic = new sns.Topic(stack, 'Topic'); + + const alarmLambda = new lambda.Function(stack, 'Lambda', { + runtime: lambda.Runtime.NODEJS_20_X, + handler: 'index.handler', + code: lambda.Code.fromInline('exports.handler = async (event) => { console.log(event); }'), + }); + + new ecsAlarms.EcsServiceRecommendedAlarms(stack, 'ecsServiceAlarms', { + service: stack.service, + defaultAlarmAction: new cloudwatch_actions.SnsAction(topic), + defaultOkAction: new cloudwatch_actions.SnsAction(topic), + defaultInsufficientDataAction: new cloudwatch_actions.SnsAction(topic), + configCpuUtilizationAlarm: { + alarmAction: new cloudwatch_actions.LambdaAction(alarmLambda), + okAction: new cloudwatch_actions.LambdaAction(alarmLambda), + insufficientDataAction: new cloudwatch_actions.LambdaAction(alarmLambda), + }, + configMemoryUtilizationAlarm: { + threshold: 10, + alarmAction: new cloudwatch_actions.LambdaAction(alarmLambda), + okAction: new cloudwatch_actions.LambdaAction(alarmLambda), + insufficientDataAction: new cloudwatch_actions.LambdaAction(alarmLambda), + }, + configEphemeralStorageUtilizedAlarm: { + threshold: 5, + alarmAction: new cloudwatch_actions.LambdaAction(alarmLambda), + okAction: new cloudwatch_actions.LambdaAction(alarmLambda), + insufficientDataAction: new cloudwatch_actions.LambdaAction(alarmLambda), + }, + configRunningTaskCountAlarm: { + threshold: 0, + alarmAction: new cloudwatch_actions.LambdaAction(alarmLambda), + okAction: new cloudwatch_actions.LambdaAction(alarmLambda), + insufficientDataAction: new cloudwatch_actions.LambdaAction(alarmLambda), + }, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); + + Object.values(ecsAlarms.EcsRecommendedAlarmsMetrics).forEach(metricName => { + template.hasResourceProperties('AWS::CloudWatch::Alarm', Match.objectLike({ + MetricName: metricName, + AlarmActions: [Match.objectLike({ 'Fn::GetAtt': [Match.stringLikeRegexp('^Lambda.*'), 'Arn'] })], + OKActions: [Match.objectLike({ 'Fn::GetAtt': [Match.stringLikeRegexp('^Lambda.*'), 'Arn'] })], + InsufficientDataActions: [Match.objectLike({ 'Fn::GetAtt': [Match.stringLikeRegexp('^Lambda.*'), 'Arn'] })], + })); + }); +}); + +test('optional alarm configurations can be overwritten', () => { + const app = new App(); + const appAspects = Aspects.of(app); + const stack = new Stack(app, 'TestStack', { + env: { + account: '123456789012', // not a real account + region: 'us-east-1', + }, + }); + + const topic = new sns.Topic(stack, 'Topic'); + const topicAction = new cloudwatch_actions.SnsAction(topic); + + appAspects.add( + new ecsAlarms.EcsRecommendedAlarmsAspect({ + configCpuUtilizationAlarm: { + alarmName: 'CustomCpuUtilizationAlarm', + threshold: 10, + period: Duration.minutes(5), + evaluationPeriods: 25, + datapointsToAlarm: 25, + alarmDescription: 'Custom alarm description', + treatMissingData: cloudwatch.TreatMissingData.IGNORE, + alarmAction: topicAction, + okAction: topicAction, + insufficientDataAction: topicAction, + }, + configMemoryUtilizationAlarm: { + alarmName: 'CustomMemoryUtilizationAlarm', + threshold: 10, + period: Duration.minutes(5), + evaluationPeriods: 25, + datapointsToAlarm: 25, + alarmDescription: 'Custom alarm description', + treatMissingData: cloudwatch.TreatMissingData.IGNORE, + alarmAction: topicAction, + okAction: topicAction, + insufficientDataAction: topicAction, + }, + configEphemeralStorageUtilizedAlarm: { + alarmName: 'CustomEphemeralStorageUtilizedAlarm', + threshold: 5, + period: Duration.minutes(5), + evaluationPeriods: 25, + datapointsToAlarm: 25, + alarmDescription: 'Custom alarm description', + treatMissingData: cloudwatch.TreatMissingData.IGNORE, + alarmAction: topicAction, + okAction: topicAction, + insufficientDataAction: topicAction, + }, + configRunningTaskCountAlarm: { + alarmName: 'CustomRunningTaskCountAlarm', + threshold: 20, + period: Duration.minutes(5), + evaluationPeriods: 25, + datapointsToAlarm: 25, + alarmDescription: 'Custom alarm description', + treatMissingData: cloudwatch.TreatMissingData.IGNORE, + alarmAction: topicAction, + okAction: topicAction, + insufficientDataAction: topicAction, + }, + }), + ); + + const cluster = new ecs.Cluster(stack, 'Cluster', { + vpc: new ec2.Vpc(stack, 'VPC'), + containerInsights: true, + clusterName: 'TestCluster', + }); + + const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', { + memoryLimitMiB: 512, + cpu: 256, + }); + + taskDefinition.addContainer('Container', { + image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), + memoryLimitMiB: 512, + cpu: 256, + }); + + const service = new ecsAlarms.FargateService(stack, 'Service1', { + cluster, + taskDefinition, + }); + + service.autoScaleTaskCount({ + minCapacity: 1, + maxCapacity: 10, + }); + + const template = Template.fromStack(stack); + expect(template).toMatchSnapshot(); + + Object.values(ecsAlarms.EcsRecommendedAlarmsMetrics).forEach(metricName => { + template.hasResourceProperties('AWS::CloudWatch::Alarm', Match.objectLike({ + MetricName: metricName, + AlarmName: Match.stringLikeRegexp('^Custom.*'), + Period: 300, + EvaluationPeriods: 25, + DatapointsToAlarm: 25, + AlarmDescription: 'Custom alarm description', + TreatMissingData: 'ignore', + AlarmActions: [Match.objectLike({ Ref: Match.stringLikeRegexp('^Topic.*') })], + OKActions: [Match.objectLike({ Ref: Match.stringLikeRegexp('^Topic.*') })], + InsufficientDataActions: [Match.objectLike({ Ref: Match.stringLikeRegexp('^Topic.*') })], + })); + }); +});