|
1 | 1 | import { Match, Template } from '../../assertions';
|
2 | 2 | import * as iam from '../../aws-iam';
|
3 | 3 | import * as cdk from '../../core';
|
| 4 | +import * as cxapi from '../../cx-api'; |
4 | 5 | import * as s3 from '../lib';
|
5 | 6 |
|
6 | 7 | describe('notification', () => {
|
@@ -226,6 +227,45 @@ describe('notification', () => {
|
226 | 227 | },
|
227 | 228 | });
|
228 | 229 | });
|
| 230 | + |
| 231 | + test('Notification custom resource uses always treat bucket as unmanaged', () => { |
| 232 | + // GIVEN |
| 233 | + const stack = new cdk.Stack(); |
| 234 | + |
| 235 | + stack.node.setContext(cxapi.S3_KEEP_NOTIFICATION_IN_IMPORTED_BUCKET, true); |
| 236 | + |
| 237 | + // WHEN |
| 238 | + new s3.Bucket(stack, 'MyBucket', { |
| 239 | + eventBridgeEnabled: true, |
| 240 | + }); |
| 241 | + |
| 242 | + // THEN |
| 243 | + Template.fromStack(stack).resourceCountIs('AWS::S3::Bucket', 1); |
| 244 | + Template.fromStack(stack).hasResourceProperties('Custom::S3BucketNotifications', { |
| 245 | + NotificationConfiguration: { |
| 246 | + EventBridgeConfiguration: {}, |
| 247 | + }, |
| 248 | + Managed: false, |
| 249 | + }); |
| 250 | + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { |
| 251 | + PolicyDocument: { |
| 252 | + Statement: [ |
| 253 | + { |
| 254 | + Action: 's3:PutBucketNotification', |
| 255 | + Effect: 'Allow', |
| 256 | + Resource: '*', |
| 257 | + }, |
| 258 | + { |
| 259 | + Action: 's3:GetBucketNotification', |
| 260 | + Effect: 'Allow', |
| 261 | + Resource: '*', |
| 262 | + }, |
| 263 | + ], |
| 264 | + Version: '2012-10-17', |
| 265 | + }, |
| 266 | + }); |
| 267 | + }); |
| 268 | + |
229 | 269 | test('check notifications handler runtime version', () => {
|
230 | 270 | const stack = new cdk.Stack();
|
231 | 271 |
|
|
0 commit comments