Skip to content

Commit 4ef156b

Browse files
committed
feat(aws-iam)!: change IEncryptedResource to extend IEnvironmentAware
BREAKING CHANGE: `IEncryptedResource` now extends `IEnvironmentAware` instead of `cdk.IResource`. The `GrantableResources.isEncryptedResource()` method now requires an `IEnvironmentAware` parameter instead of `IConstruct`.
1 parent 06676ac commit 4ef156b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

allowed-breaking-changes.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4142,3 +4142,12 @@ changed-type:aws-cdk-lib.aws_ses.EventDestination.bus
41424142
# CloudFormation has always required SecurityGroups for ManagedInstancesCapacityProvider.
41434143
# Making it required in TypeScript catches the error at compile time instead of deploy time.
41444144
strengthened:aws-cdk-lib.aws_ecs.ManagedInstancesCapacityProviderProps
4145+
4146+
# IEncryptedResource was too strongly typed for practical use.
4147+
# We need to weaken it and align with other traits.
4148+
# See: https://github.com/aws/aws-cdk/pull/36787
4149+
incompatible-argument:aws-cdk-lib.aws_iam.GrantableResources.isEncryptedResource
4150+
base-types:aws-cdk-lib.aws_iam.IEncryptedResource
4151+
removed:aws-cdk-lib.aws_iam.IEncryptedResource.applyRemovalPolicy
4152+
removed:aws-cdk-lib.aws_iam.IEncryptedResource.node
4153+
removed:aws-cdk-lib.aws_iam.IEncryptedResource.stack

packages/aws-cdk-lib/aws-iam/lib/grant.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,9 @@ export interface GrantOnKeyResult {
433433
}
434434

435435
/**
436-
* A resource that contains data that can be encrypted, using a KMS key.
437-
*
438-
* [awslint:interface-extends-ref]
436+
* A resource that contains data that can be encrypted, using a KMS key.s
439437
*/
440-
export interface IEncryptedResource extends cdk.IResource {
438+
export interface IEncryptedResource extends IEnvironmentAware {
441439
/**
442440
* Gives permissions to a grantable entity to perform actions on the encryption key.
443441
*/
@@ -468,7 +466,7 @@ export class GrantableResources {
468466
/**
469467
* Whether this resource holds data that can be encrypted using a KMS key.
470468
*/
471-
static isEncryptedResource(resource: IConstruct): resource is iam.IEncryptedResource {
469+
static isEncryptedResource(resource: IEnvironmentAware): resource is iam.IEncryptedResource {
472470
return (resource as unknown as iam.IEncryptedResource).grantOnKey !== undefined;
473471
}
474472
}

0 commit comments

Comments
 (0)