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
Copy file name to clipboardExpand all lines: src/content/docs/aws/tutorials/iam-policy-stream.mdx
+40-28Lines changed: 40 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ When you're developing cloud and serverless applications, you need to grant acce
19
19
To handle this, you create IAM roles and assign permissions through policies.
20
20
However, configuring these policies can be challenging, especially if you want to ensure minimal access of all principals to your resources.
21
21
22
-
[LocalStack IAM Policy Stream](https://app.localstack.cloud/policy-stream) automates the generation of IAM policies for your AWS API requests on your local machine.
22
+
[LocalStack IAM Policy Stream](https://app.localstack.cloud/inst/default/policy-stream) automates the generation of IAM policies for your AWS API requests on your local machine.
23
23
This stream helps you identify the necessary permissions for your cloud application and allows you to detect logical errors, such as unexpected actions in your policies.
24
24
25
25
This tutorial will guide you through setting up IAM Policy Stream for a locally running AWS application.
@@ -41,10 +41,10 @@ Additionally, it serves as a useful learning tool, helping users understand the
41
41
42
42
## Prerequisites
43
43
44
-
-[LocalStack CLI](/aws/getting-started/installation) with [`LOCALSTACK_AUTH_TOKEN`](/aws/getting-started/auth-token)
44
+
-[`lstk`](/aws/getting-started/installation#lstk) with [`LOCALSTACK_AUTH_TOKEN`](/aws/getting-started/auth-token)
Access the [LocalStack Web Application](https://app.localstack.cloud/) and go to the [IAM Policy Stream dashboard](https://app.localstack.cloud/policy-stream).
148
+
Access the [LocalStack Web Application](https://app.localstack.cloud/) and go to the [IAM Policy Stream dashboard](https://app.localstack.cloud/inst/default/policy-stream).
149
149
This feature enables you to directly examine the generated policies, displaying the precise permissions required for each API call.
Uploading a file will activate an event notification, sending a message to the SQS queue.
166
-
However, since the SQS queue lacks the necessary permissions, an IAM violation will appear in the [IAM Policy Stream dashboard](https://app.localstack.cloud/policy-stream).
166
+
However, since the SQS queue lacks the necessary permissions, an IAM violation will appear in the [IAM Policy Stream dashboard](https://app.localstack.cloud/inst/default/policy-stream).
167
167
168
168

169
169
@@ -221,14 +221,14 @@ POLICY
221
221
Now, re-apply the Terraform configuration to update the SQS queue with the new policy:
222
222
223
223
```bash
224
-
tflocal apply
224
+
lstk terraform apply
225
225
```
226
226
227
227
Next, trigger the event notification again by uploading a file to the S3 bucket.
228
228
You can confirm that the S3 bucket is correctly set up for event notifications through the SQS queue by checking if the message is received in the SQS queue:
@@ -273,13 +273,13 @@ This section demonstrates how to test your IAM policies and verify both deny and
273
273
274
274
### Testing Scenario 1: Deny (Without IAM Policy)
275
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.
276
+
When you first upload a file to the S3 bucket without the proper SQS queue policy in place, S3 has no permission to send messages to the SQS queue, and the violation is reported.
Or you may receive no output at all, indicating an empty queue.
327
+
:::note
328
+
In a production environment, where the same policy gap would be enforced by real AWS IAM, this `SendMessage` call would fail and the message would never arrive.
329
+
:::
321
330
322
331
### Testing Scenario 2: Allow (With IAM Policy)
323
332
@@ -353,7 +362,7 @@ After applying the IAM policy generated by the Policy Stream to your SQS queue,
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'"]
376
+
An allowed request produces no output from the IAM policy handler — only denials are logged.
377
+
378
+
```bash
379
+
lstk logs | grep "i.p.handler"
370
380
```
371
381
382
+
Only the entries from the earlier, un-permitted upload should remain.
383
+
372
384
**IAM Policy Stream Dashboard showing no violations:**
373
385
374
386

@@ -378,7 +390,7 @@ The dashboard shows all actions with green checkmarks, indicating successful exe
0 commit comments