-
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): encryptionType is incorrect when encryptionMasterKey is pro…
…vided (#26886) In #19796 we added additional validation to sns subscription. For that purpose the Queue `encryptionType` was exposed as a public property. However the PR forgot to take into account that the provided `encryption` property is automatically changed when a `encryptionMasterKey` is provided. This PR ensures that the public `encryptionType` has the correct value. Additionally, adds a warning for an incorrect configuration scenario where `encryptionMasterKey` is provided together with an `encryption` other than QueueEncryption.KMS. This feature was supposed to allow users to simply provide an encryption key and have the encryption type being selected automatically. However it now unintentionally allows for wrong configurations that are silently fixed, e.g. setting QueueEncryption.UNENCRYPTED and providing an encryption key. The warning keeps backwards compatibility, but instructs users to fix their configuration. Closes #26719 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
3 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/aws-cdk-lib/aws-sns-subscriptions/test/sqs.test.ts
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Template } from '../../assertions'; | ||
import * as kms from '../../aws-kms'; | ||
import * as sns from '../../aws-sns'; | ||
import * as sqs from '../../aws-sqs'; | ||
import { Stack } from '../../core'; | ||
import * as subscriptions from '../lib'; | ||
|
||
test('can add subscription to queue that has encryptionType auto changed', () => { | ||
// GIVEN | ||
const stack = new Stack(); | ||
const key = new kms.Key(stack, 'CustomKey'); | ||
const queue = new sqs.Queue(stack, 'Queue', { | ||
encryption: sqs.QueueEncryption.KMS_MANAGED, | ||
encryptionMasterKey: key, | ||
}); | ||
|
||
const someTopic = new sns.Topic(stack, 'Topic'); | ||
someTopic.addSubscription( | ||
new subscriptions.SqsSubscription(queue, { | ||
rawMessageDelivery: true, | ||
}), | ||
); | ||
|
||
// THEN | ||
Template.fromStack(stack).hasResourceProperties('AWS::SNS::Subscription', { | ||
Endpoint: { | ||
'Fn::GetAtt': ['Queue4A7E3555', 'Arn'], | ||
}, | ||
Protocol: 'sqs', | ||
}); | ||
}); |
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