`aws-sqs`: grantSendMessages() auto provisions encryption settings but grant() does not
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
if you provision permissions to a queue using grantSendMessages(), CDK [auto provisions KMS access](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-sqs/lib/queue-base.ts#L209-L212). using grant() [does not.](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-sqs/lib/queue-base.ts#L96)
### Expected Behavior
either grant should auto provision kms access (when necessary) or there should be a parameter flag to automatically set it
### Current Behavior
does not grant access to kms keys required to interact with the queue
### Reproduction Steps
n/a
### Possible Solution
feature flag to auto set permissions. could be a enum using these permission settings: https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-kms/lib/private/perms.ts#L3-L28
```
const perms = [
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl",
"sqs:SendMessage",
"sqs:SendMessageBatch"
]
myQueue.grant(
new AccountPrincipal(acnt),
'DECRYPT_ACTIONS',
...perms
)}
```
### Additional Information/Context
_No response_
### CDK CLI Version
2.20
### Framework Version
_No response_
### Node.js Version
14x
### OS
al2
### Language
Typescript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start in packages/@aws-cdk/aws-sqs/lib/queue-base.ts by comparing grant() with grantSendMessages(), then review the KMS permission definitions in packages/@aws-cdk/aws-kms/lib/private/perms.ts. Clarify whether both grants should provision KMS access or whether an explicit permission option is required, and verify the chosen behavior for encrypted queues.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100