# EncryptedResources

Utility class for discovering and registering encrypted resource traits.

This class provides methods to retrieve IEncryptedResource instances from constructs,
enabling automatic KMS key permission grants during IAM grant operations.

- Source: [`aws-iam/lib/grant.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-iam/lib/grant.ts#L480)
- Type last changed: v2.239.0 · 19 Feb 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_iam as iam } from 'aws-cdk-lib';
const encryptedResources = new iam.EncryptedResources();
```

Python:

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

encrypted_resources = iam.EncryptedResources()
```

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

EncryptedResources encryptedResources = new EncryptedResources();
```

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.AWS.IAM;

var encryptedResources = new EncryptedResources();
```

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 "github.com/aws/aws-cdk-go/awscdk"

encryptedResources := awscdk.Aws_iam.NewEncryptedResources()
```

## Initializer

TypeScript:

```ts
new EncryptedResources()
```

Python:

```python
EncryptedResources()
```

Java:

```java
new EncryptedResources()
```

C# / .NET:

```csharp
new EncryptedResources()
```

Golang:

```go
NewEncryptedResources()
```

## Methods

- `of(resource: IEnvironmentAware): IEncryptedResource` (static) — Retrieve the IEncryptedResource associated with a construct, if available.

- `register(scope: IConstruct, cfnType: string, factory: IEncryptedResourceFactory): void` (static) — Register a factory for a specific CloudFormation resource type and scope.
