You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. An **S3 bucket** is configured to send event notifications when objects are created
59
+
2. An **SQS queue** receives these notifications
60
+
3. The **IAM Enforcement Engine** intercepts API calls and checks for proper permissions
61
+
4. The **IAM Policy Stream Dashboard** captures all API requests and generates the necessary IAM policies
62
+
5. When a file is uploaded to the S3 bucket, S3 attempts to send a message to SQS, which initially fails due to missing permissions
63
+
6. The IAM Policy Stream automatically generates the required policy, which can then be applied to resolve the violation
64
+
51
65
## Tutorial: Configure an S3 bucket for event notifications using SQS
52
66
53
67
In this tutorial, you will configure a LocalStack S3 bucket to send event notifications to an SQS queue.
@@ -253,6 +267,147 @@ For larger AWS applications, you would be able to find multiple roles and multip
253
267
254
268

255
269
270
+
## Testing the application
271
+
272
+
This section demonstrates how to test your IAM policies and verify both deny and allow scenarios using LocalStack's IAM enforcement.
273
+
274
+
### Testing Scenario 1: Deny (Without IAM Policy)
275
+
276
+
When you first upload a file to the S3 bucket without the proper SQS queue policy in place, the S3 service will be denied permission to send messages to the SQS queue.
**Expected output - IAM Violation in LocalStack logs:**
286
+
287
+
```shell
288
+
2024-07-09T05:30:33.583 INFO --- [et.reactor-4] l.s.i.p.handler : Request for service 'sqs' by principal 's3.amazonaws.com'for operation 'SendMessage' denied.
289
+
2024-07-09T05:30:33.583 DEBUG --- [et.reactor-4] l.s.i.p.handler : Necessary permissions for this action: ["Action 'sqs:SendMessage' for 'arn:aws:sqs:us-east-1:000000000000:s3-event-notification-queue'"]
290
+
2024-07-09T05:30:33.583 DEBUG --- [et.reactor-4] l.s.i.p.handler : 0 permissions have been explicitly denied: []
291
+
2024-07-09T05:30:33.583 DEBUG --- [et.reactor-4] l.s.i.p.handler : 0 permissions have been explicitly allowed: []
292
+
2024-07-09T05:30:33.583 DEBUG --- [et.reactor-4] l.s.i.p.handler : 1 permissions have been implicitly denied: ["Action 'sqs:SendMessage' for 'arn:aws:sqs:us-east-1:000000000000:s3-event-notification-queue'"]
293
+
```
294
+
295
+
**IAM Policy Stream Dashboard showing the violation:**
296
+
297
+

2024-07-09T05:35:22.123 DEBUG --- [et.reactor-2] l.s.i.p.handler : Request for service 'sqs' by principal 's3.amazonaws.com'for operation 'SendMessage' allowed.
369
+
2024-07-09T05:35:22.123 DEBUG --- [et.reactor-2] l.s.i.p.handler : 1 permissions have been explicitly allowed: ["Action 'sqs:SendMessage' for 'arn:aws:sqs:us-east-1:000000000000:s3-event-notification-queue'"]
370
+
```
371
+
372
+
**IAM Policy Stream Dashboard showing no violations:**
373
+
374
+

375
+
376
+
The dashboard shows all actions with green checkmarks, indicating successful execution.
The message body contains the S3 event notification with details about the uploaded file, confirming that the IAM policy is working correctly.
401
+
402
+
### Verification Checklist
403
+
404
+
To ensure your IAM policies are correctly configured:
405
+
406
+
-**No IAM violations** appear in the IAM Policy Stream dashboard
407
+
-**Messages are successfully delivered** to the SQS queue
408
+
-**LocalStack logs show "allowed"** for the `SendMessage` operation
409
+
-**All API calls display green checkmarks** in the Policy Stream dashboard
410
+
256
411
## Conclusion
257
412
258
413
IAM Policy Stream streamlines your development process by minimizing the manual creation of policies and confirming the necessity of granted permissions.
0 commit comments