-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sqs): do not emit grants to the AWS-managed encryption key (#3169)
Grants on the `alias/aws/sqs` KMS key alias are not necessary since the key will implicitly allow for it's intended usage to be fulfilled (as opposed to how you have to manage grants yourself when using a user-managed key instead). This removes the statement that was generated using an invalid resource entry. Fixes #2794
- Loading branch information
1 parent
fac7c61
commit 07f017b
Showing
5 changed files
with
194 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
import { App, CfnOutput, Stack } from '@aws-cdk/core'; | ||
import { Queue } from '../lib'; | ||
import { AccountRootPrincipal, Role } from '@aws-cdk/aws-iam'; | ||
import { Key } from '@aws-cdk/aws-kms'; | ||
import { App, CfnOutput, RemovalPolicy, Stack } from '@aws-cdk/core'; | ||
import { Queue, QueueEncryption } from '../lib'; | ||
|
||
const app = new App(); | ||
|
||
const stack = new Stack(app, 'aws-cdk-sqs'); | ||
|
||
const dlq = new Queue(stack, 'DeadLetterQueue'); | ||
const queue = new Queue(stack, 'Queue', { | ||
deadLetterQueue: { queue: dlq, maxReceiveCount: 5 } | ||
deadLetterQueue: { queue: dlq, maxReceiveCount: 5 }, | ||
encryption: QueueEncryption.KMS_MANAGED, | ||
}); | ||
const fifo = new Queue(stack, 'FifoQueue', { | ||
fifo: true, | ||
encryptionMasterKey: new Key(stack, 'EncryptionKey', { removalPolicy: RemovalPolicy.DESTROY }) | ||
}); | ||
|
||
new Queue(stack, 'FifoQueue', { | ||
fifo: true | ||
const role = new Role(stack, 'Role', { | ||
assumedBy: new AccountRootPrincipal(), | ||
}); | ||
|
||
dlq.grantConsumeMessages(role); | ||
queue.grantConsumeMessages(role); | ||
fifo.grantConsumeMessages(role); | ||
|
||
new CfnOutput(stack, 'QueueUrl', { value: queue.queueUrl }); | ||
|
||
app.synth(); |