-
Notifications
You must be signed in to change notification settings - Fork 4.3k
chore(ec2): extract grant logic to a helper class #35715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
readonly policyDependable?: IDependable; | ||
} | ||
|
||
export interface IResourceWithKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming suggestions are welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IEncryptedResource
?
IEncryptableResource
?
return new VolumeGrants(volume); | ||
} | ||
|
||
public static fromVolumeWithKey(volume: IVolumeRef & IResourceWithKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No intersections yet please :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(May just mean we need to wait a bit before merging this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked with do-not-merge
.
readonly policyDependable?: IDependable; | ||
} | ||
|
||
export interface IResourceWithKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IEncryptedResource
?
IEncryptableResource
?
} | ||
|
||
export interface IResourceWithKey { | ||
grantKey(grantee: IGrantable, actions: string[], conditions?: Record<string, Record<string, unknown>>): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addToKeyPolicy()
? With a Statement
?
(Although I guess that's not entirely the thing, is it...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would be better. The only question is: a PolicyStatement
may have many principals. Should we grant the permission to all of them?
Move the logic from
VolumeBase.grantAttachVolumeByResourceTag()
andVolumeBase.grantAttachVolume()
to a new helper class, calledVolumeGrants
. With this, we can give grants to L1s and L2s in a uniform way:If the instance of
IVolumeRef
that we have also happens to implementIResourceWithKey
, we can do:which will also give the grantee permission to
kms:CreateGrant
on the encryption key, if one is defined.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license