-
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(sns-subscriptions): restrict encryption of queue to only the resp…
…ective sns topic (under feature flag) (#20521) Implements #20339 The change adds a conditional that only the corresponding SNS Topic can decrypt the SQS queue with the KMS-Key if one was given. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *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
7 changed files
with
358 additions
and
102 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
257 changes: 159 additions & 98 deletions
257
...s-cdk/aws-sns-subscriptions/test/sns-sqs.lit.integ.snapshot/aws-cdk-sns-sqs.template.json
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,110 +1,171 @@ | ||
{ | ||
"Resources": { | ||
"MyTopic86869434": { | ||
"Type": "AWS::SNS::Topic" | ||
}, | ||
"MyQueueE6CA6235": { | ||
"Type": "AWS::SQS::Queue", | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"MyQueuePolicy6BBEDDAC": { | ||
"Type": "AWS::SQS::QueuePolicy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sqs:SendMessage", | ||
"Condition": { | ||
"ArnEquals": { | ||
"aws:SourceArn": { | ||
"Ref": "MyTopic86869434" | ||
} | ||
"Resources": { | ||
"MyTopic86869434": { | ||
"Type": "AWS::SNS::Topic" | ||
}, | ||
"MyQueueE6CA6235": { | ||
"Type": "AWS::SQS::Queue", | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete", | ||
"Properties": { | ||
"KmsMasterKeyId": { | ||
"Fn::GetAtt": [ | ||
"EncryptionMasterKey5BD393B9", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "sns.amazonaws.com" | ||
}, | ||
"Resource": { | ||
"Fn::GetAtt": [ | ||
"MyQueueE6CA6235", | ||
"Arn" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Queues": [ | ||
{ | ||
"Ref": "MyQueueE6CA6235" | ||
} | ||
] | ||
} | ||
}, | ||
"MyQueueawscdksnssqsMyTopic9361DEA223429051": { | ||
"Type": "AWS::SNS::Subscription", | ||
"Properties": { | ||
"Protocol": "sqs", | ||
"TopicArn": { | ||
"Ref": "MyTopic86869434" | ||
}, | ||
"Endpoint": { | ||
"Fn::GetAtt": [ | ||
"MyQueueE6CA6235", | ||
"Arn" | ||
] | ||
"MyQueuePolicy6BBEDDAC": { | ||
"Type": "AWS::SQS::QueuePolicy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sqs:SendMessage", | ||
"Condition": { | ||
"ArnEquals": { | ||
"aws:SourceArn": { | ||
"Ref": "MyTopic86869434" | ||
} | ||
} | ||
}, | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "sns.amazonaws.com" | ||
}, | ||
"Resource": { | ||
"Fn::GetAtt": [ | ||
"MyQueueE6CA6235", | ||
"Arn" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Queues": [ | ||
{ | ||
"Ref": "MyQueueE6CA6235" | ||
} | ||
] | ||
} | ||
}, | ||
"RedrivePolicy": { | ||
"deadLetterTargetArn": { | ||
"Fn::GetAtt": [ | ||
"DeadLetterQueue9F481546", | ||
"Arn" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"DeadLetterQueue9F481546": { | ||
"Type": "AWS::SQS::Queue", | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"DeadLetterQueuePolicyB1FB890C": { | ||
"Type": "AWS::SQS::QueuePolicy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sqs:SendMessage", | ||
"Condition": { | ||
"ArnEquals": { | ||
"aws:SourceArn": { | ||
"MyQueueawscdksnssqsMyTopic9361DEA223429051": { | ||
"Type": "AWS::SNS::Subscription", | ||
"Properties": { | ||
"Protocol": "sqs", | ||
"TopicArn": { | ||
"Ref": "MyTopic86869434" | ||
} | ||
}, | ||
"Endpoint": { | ||
"Fn::GetAtt": [ | ||
"MyQueueE6CA6235", | ||
"Arn" | ||
] | ||
}, | ||
"RedrivePolicy": { | ||
"deadLetterTargetArn": { | ||
"Fn::GetAtt": [ | ||
"DeadLetterQueue9F481546", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "sns.amazonaws.com" | ||
}, | ||
"Resource": { | ||
"Fn::GetAtt": [ | ||
"DeadLetterQueue9F481546", | ||
"Arn" | ||
} | ||
}, | ||
"DeadLetterQueue9F481546": { | ||
"Type": "AWS::SQS::Queue", | ||
"UpdateReplacePolicy": "Delete", | ||
"DeletionPolicy": "Delete" | ||
}, | ||
"DeadLetterQueuePolicyB1FB890C": { | ||
"Type": "AWS::SQS::QueuePolicy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sqs:SendMessage", | ||
"Condition": { | ||
"ArnEquals": { | ||
"aws:SourceArn": { | ||
"Ref": "MyTopic86869434" | ||
} | ||
} | ||
}, | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "sns.amazonaws.com" | ||
}, | ||
"Resource": { | ||
"Fn::GetAtt": [ | ||
"DeadLetterQueue9F481546", | ||
"Arn" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Queues": [ | ||
{ | ||
"Ref": "DeadLetterQueue9F481546" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Queues": [ | ||
{ | ||
"Ref": "DeadLetterQueue9F481546" | ||
} | ||
] | ||
} | ||
"EncryptionMasterKey5BD393B9": { | ||
"Type": "AWS::KMS::Key", | ||
"Properties": { | ||
"KeyPolicy": { | ||
"Statement": [ | ||
{ | ||
"Action": "kms:*", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":root" | ||
] | ||
] | ||
} | ||
}, | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Action": [ | ||
"kms:Decrypt", | ||
"kms:GenerateDataKey" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "sns.amazonaws.com" | ||
}, | ||
"Condition": { | ||
"ArnEquals": { | ||
"aws:SourceArn": { | ||
"Ref": "MyTopic86869434" | ||
} | ||
} | ||
}, | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
}, | ||
"DeletionPolicy": "Retain", | ||
"UpdateReplacePolicy": "Retain" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.