# CfnResourceMetadataContext

Manages resource-level CloudFormation Metadata Context.

Obtainable from: CfnResourceMetadataContext.of

- Source: [`core/lib/metadata-context.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/core/lib/metadata-context.ts#L252)
- Type last changed: v2.278.0 · 20 Nov 2026

## 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';

declare const constructSelector: cdk.IConstructSelector;
const cfnResourceMetadataContext = cdk.CfnResourceMetadataContext.of(this, /* all optional props */ {
  selector: constructSelector,
});
```

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

# construct_selector: cdk.IConstructSelector

cfn_resource_metadata_context = cdk.CfnResourceMetadataContext.of(self,
    selector=construct_selector
)
```

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.*;

IConstructSelector constructSelector;

CfnResourceMetadataContext cfnResourceMetadataContext = CfnResourceMetadataContext.of(this, CfnResourceMetadataContextOptions.builder()
        .selector(constructSelector)
        .build());
```

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;

IConstructSelector constructSelector;

var cfnResourceMetadataContext = CfnResourceMetadataContext.Of(this, new CfnResourceMetadataContextOptions {
    Selector = constructSelector
});
```

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"

var constructSelector IConstructSelector

cfnResourceMetadataContext := cdk.CfnResourceMetadataContext_Of(this, &CfnResourceMetadataContextOptions{
	Selector: constructSelector,
})
```

## Methods

- `clear(): void` — Removes Context from the selected resources.

- `of(scope: IConstruct, options?: CfnResourceMetadataContextOptions): CfnResourceMetadataContext // chainable` (static) — Returns the resource context API for a construct scope.

  **Parameters**

  - `scope` — The scope whose resources receive the context.
  - `options` — Resource selection options.

- `set(context: CfnResourceMetadataContextProps): void` — Replaces the complete Context value on the selected resources.

  Includes resources added after this call.
