Skip to content
v2.274.0

Annotations Class ​

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

Focused on asserting annotations.

Example ​

ts
// 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 ​

findError(constructPath: string, message: any): SynthesisMessage[]def find_error(self, construct_path: str, message: Any) -> typing.List[SynthesisMessage]public List<SynthesisMessage> findError(String constructPath, Object message)public SynthesisMessage[] FindError(string constructPath, object message)func FindError(ConstructPath *string, Message interface{}) *[]SynthesisMessage#
Get the set of matching errors of a given construct path and message.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the error, provide '*' to match all errors in the template.
  • messagemessagemessagemessageMessage — the error message as should be expected.
findInfo(constructPath: string, message: any): SynthesisMessage[]def find_info(self, construct_path: str, message: Any) -> typing.List[SynthesisMessage]public List<SynthesisMessage> findInfo(String constructPath, Object message)public SynthesisMessage[] FindInfo(string constructPath, object message)func FindInfo(ConstructPath *string, Message interface{}) *[]SynthesisMessage#
Get the set of matching infos of a given construct path and message.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the info, provide '*' to match all infos in the template.
  • messagemessagemessagemessageMessage — the info message as should be expected.
findWarning(constructPath: string, message: any): SynthesisMessage[]def find_warning(self, construct_path: str, message: Any) -> typing.List[SynthesisMessage]public List<SynthesisMessage> findWarning(String constructPath, Object message)public SynthesisMessage[] FindWarning(string constructPath, object message)func FindWarning(ConstructPath *string, Message interface{}) *[]SynthesisMessage#
Get the set of matching warning of a given construct path and message.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the warning, provide '*' to match all warnings in the template.
  • messagemessagemessagemessageMessage — the warning message as should be expected.
fromStack(stack: Stack): Annotations // chainable@staticmethod def from_stack(stack: Stack) -> Annotationspublic static Annotations fromStack(Stack stack)public static Annotations FromStack(Stack stack)func FromStack(Stack Stack) Annotationsstatic#
Base your assertions on the messages returned by a synthesized CDK `Stack`.
1 parameter

Parameters

  • stackstackstackstackStack — the CDK Stack to run assertions on.
hasError(constructPath: string, message: any): voiddef has_error(self, construct_path: str, message: Any) -> Nonepublic void hasError(String constructPath, Object message)public void HasError(string constructPath, object message)func HasError(ConstructPath *string, Message interface{})#
Assert that an error with the given message exists in the synthesized CDK `Stack`.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the error, provide '*' to match all errors in the template.
  • messagemessagemessagemessageMessage — the error message as should be expected.
hasInfo(constructPath: string, message: any): voiddef has_info(self, construct_path: str, message: Any) -> Nonepublic void hasInfo(String constructPath, Object message)public void HasInfo(string constructPath, object message)func HasInfo(ConstructPath *string, Message interface{})#
Assert that an info with the given message exists in the synthesized CDK `Stack`.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the info, provide '*' to match all info in the template.
  • messagemessagemessagemessageMessage — the info message as should be expected.
hasNoError(constructPath: string, message: any): voiddef has_no_error(self, construct_path: str, message: Any) -> Nonepublic void hasNoError(String constructPath, Object message)public void HasNoError(string constructPath, object message)func HasNoError(ConstructPath *string, Message interface{})#
Assert that an error with the given message does not exist in the synthesized CDK `Stack`.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the error, provide '*' to match all errors in the template.
  • messagemessagemessagemessageMessage — the error message as should be expected.
hasNoInfo(constructPath: string, message: any): voiddef has_no_info(self, construct_path: str, message: Any) -> Nonepublic void hasNoInfo(String constructPath, Object message)public void HasNoInfo(string constructPath, object message)func HasNoInfo(ConstructPath *string, Message interface{})#
Assert that an info with the given message does not exist in the synthesized CDK `Stack`.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the info, provide '*' to match all info in the template.
  • messagemessagemessagemessageMessage — the info message as should be expected.
hasNoWarning(constructPath: string, message: any): voiddef has_no_warning(self, construct_path: str, message: Any) -> Nonepublic void hasNoWarning(String constructPath, Object message)public void HasNoWarning(string constructPath, object message)func HasNoWarning(ConstructPath *string, Message interface{})#
Assert that a warning with the given message does not exist in the synthesized CDK `Stack`.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the warning, provide '*' to match all warnings in the template.
  • messagemessagemessagemessageMessage — the warning message as should be expected.
hasWarning(constructPath: string, message: any): voiddef has_warning(self, construct_path: str, message: Any) -> Nonepublic void hasWarning(String constructPath, Object message)public void HasWarning(string constructPath, object message)func HasWarning(ConstructPath *string, Message interface{})#
Assert that a warning with the given message exists in the synthesized CDK `Stack`.
2 parameters

Parameters

  • constructPathconstruct_pathconstructPathconstructPathConstructPath — the construct path to the warning, provide '*' to match all warnings in the template.
  • messagemessagemessagemessageMessage — the warning message as should be expected.