# Annotations

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

Focused on asserting annotations.

Obtainable from: Annotations.fromStack

- Source: [`assertions/lib/annotations.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/assertions/lib/annotations.ts#L12)
- Type last changed: v2.17.0 · 17 Mar 2022

## Example

TypeScript:

```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);
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import assertions

# stack: cdk.Stack

annotations = assertions.Annotations.from_stack(stack)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.assertions.*;

Stack stack;

Annotations annotations = Annotations.fromStack(stack);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.Assertions;

Stack stack;

var annotations = Annotations.FromStack(stack);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var stack Stack

annotations := awscdk.Assertions.Annotations_FromStack(stack)
```

## Methods

- `findError(constructPath: string, message: any): SynthesisMessage[]` — Get the set of matching errors of a given construct path and message.

  **Parameters**

  - `constructPath` — the construct path to the error, provide `'*'` to match all errors in the template.
  - `message` — the error message as should be expected.

- `findInfo(constructPath: string, message: any): SynthesisMessage[]` — Get the set of matching infos of a given construct path and message.

  **Parameters**

  - `constructPath` — the construct path to the info, provide `'*'` to match all infos in the template.
  - `message` — the info message as should be expected.

- `findWarning(constructPath: string, message: any): SynthesisMessage[]` — Get the set of matching warning of a given construct path and message.

  **Parameters**

  - `constructPath` — the construct path to the warning, provide `'*'` to match all warnings in the template.
  - `message` — the warning message as should be expected.

- `fromStack(stack: Stack): Annotations // chainable` (static) — Base your assertions on the messages returned by a synthesized CDK `Stack`.

  **Parameters**

  - `stack` — the CDK Stack to run assertions on.

- `hasError(constructPath: string, message: any): void` — Assert that an error with the given message exists in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the error, provide `'*'` to match all errors in the template.
  - `message` — the error message as should be expected.

- `hasInfo(constructPath: string, message: any): void` — Assert that an info with the given message exists in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the info, provide `'*'` to match all info in the template.
  - `message` — the info message as should be expected.

- `hasNoError(constructPath: string, message: any): void` — Assert that an error with the given message does not exist in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the error, provide `'*'` to match all errors in the template.
  - `message` — the error message as should be expected.

- `hasNoInfo(constructPath: string, message: any): void` — Assert that an info with the given message does not exist in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the info, provide `'*'` to match all info in the template.
  - `message` — the info message as should be expected.

- `hasNoWarning(constructPath: string, message: any): void` — Assert that a warning with the given message does not exist in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the warning, provide `'*'` to match all warnings in the template.
  - `message` — the warning message as should be expected.

- `hasWarning(constructPath: string, message: any): void` — Assert that a warning with the given message exists in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the warning, provide `'*'` to match all warnings in the template.
  - `message` — the warning message as should be expected.
