aws-cdk-lib.assertions.Annotations

class Annotations

LanguageType name
.NETAmazon.CDK.Assertions.Annotations
Gogithub.com/aws/aws-cdk-go/awscdk/v2/assertions#Annotations
Javasoftware.amazon.awscdk.assertions.Annotations
Pythonaws_cdk.assertions.Annotations
TypeScript (source)aws-cdk-lib » assertions » Annotations

Suite of assertions that can be run on a CDK Stack.

Focused on asserting annotations.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { assertions } from 'aws-cdk-lib';

declare const stack: cdk.Stack;
const annotations = assertions.Annotations.fromStack(stack);

Methods

NameDescription
findError(constructPath, message)Get the set of matching errors of a given construct path and message.
findInfo(constructPath, message)Get the set of matching infos of a given construct path and message.
findWarning(constructPath, message)Get the set of matching warning of a given construct path and message.
hasError(constructPath, message)Assert that an error with the given message exists in the synthesized CDK Stack.
hasInfo(constructPath, message)Assert that an info with the given message exists in the synthesized CDK Stack.
hasNoError(constructPath, message)Assert that an error with the given message does not exist in the synthesized CDK Stack.
hasNoInfo(constructPath, message)Assert that an info with the given message does not exist in the synthesized CDK Stack.
hasNoWarning(constructPath, message)Assert that an warning with the given message does not exist in the synthesized CDK Stack.
hasWarning(constructPath, message)Assert that an warning with the given message exists in the synthesized CDK Stack.
static fromStack(stack)Base your assertions on the messages returned by a synthesized CDK Stack.

findError(constructPath, message)

public findError(constructPath: string, message: any): SynthesisMessage[]

Parameters

  • constructPath string — the construct path to the error.
  • message any — the error message as should be expected.

Returns

  • SynthesisMessage[]

Get the set of matching errors of a given construct path and message.


findInfo(constructPath, message)

public findInfo(constructPath: string, message: any): SynthesisMessage[]

Parameters

  • constructPath string — the construct path to the info.
  • message any — the info message as should be expected.

Returns

  • SynthesisMessage[]

Get the set of matching infos of a given construct path and message.


findWarning(constructPath, message)

public findWarning(constructPath: string, message: any): SynthesisMessage[]

Parameters

  • constructPath string — the construct path to the warning.
  • message any — the warning message as should be expected.

Returns

  • SynthesisMessage[]

Get the set of matching warning of a given construct path and message.


hasError(constructPath, message)

public hasError(constructPath: string, message: any): void

Parameters

  • constructPath string — the construct path to the error.
  • message any — the error message as should be expected.

Assert that an error with the given message exists in the synthesized CDK Stack.


hasInfo(constructPath, message)

public hasInfo(constructPath: string, message: any): void

Parameters

  • constructPath string — the construct path to the info.
  • message any — the info message as should be expected.

Assert that an info with the given message exists in the synthesized CDK Stack.


hasNoError(constructPath, message)

public hasNoError(constructPath: string, message: any): void

Parameters

  • constructPath string — the construct path to the error.
  • message any — the error message as should be expected.

Assert that an error with the given message does not exist in the synthesized CDK Stack.


hasNoInfo(constructPath, message)

public hasNoInfo(constructPath: string, message: any): void

Parameters

  • constructPath string — the construct path to the info.
  • message any — the info message as should be expected.

Assert that an info with the given message does not exist in the synthesized CDK Stack.


hasNoWarning(constructPath, message)

public hasNoWarning(constructPath: string, message: any): void

Parameters

  • constructPath string — the construct path to the warning.
  • message any — the warning message as should be expected.

Assert that an warning with the given message does not exist in the synthesized CDK Stack.


hasWarning(constructPath, message)

public hasWarning(constructPath: string, message: any): void

Parameters

  • constructPath string — the construct path to the warning.
  • message any — the warning message as should be expected.

Assert that an warning with the given message exists in the synthesized CDK Stack.


static fromStack(stack)

public static fromStack(stack: Stack): Annotations

Parameters

  • stack Stack — the CDK Stack to run assertions on.

Returns

  • Annotations

Base your assertions on the messages returned by a synthesized CDK Stack.