Skip to content

Commit c8841f4

Browse files
whummerclaude
andcommitted
Fix IAM enforcement endpoint: use /_aws/iam/config with state payload
The correct LocalStack endpoint is POST /_aws/iam/config with {"state":"ENFORCED"} / {"state":"ALLOW_ALL"}, not /_localstack/config. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a3669f5 commit c8841f4

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

01-serverless-app/website/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -820,25 +820,25 @@ <h2>API Endpoint</h2>
820820

821821
async function checkIAM() {
822822
try {
823-
const res = await fetch(`${window.location.origin}/_localstack/config`);
823+
const res = await fetch(`${window.location.origin}/_aws/iam/config`);
824824
const data = await res.json();
825-
const on = !!(data.ENFORCE_IAM && data.ENFORCE_IAM !== "0" && data.ENFORCE_IAM !== false);
825+
const on = data.state === "ENFORCED";
826826
const toggle = document.getElementById("iam-toggle");
827827
const label = document.getElementById("iam-status-label");
828828
const hint = document.getElementById("iam-hint");
829-
toggle.checked = on;
830-
label.textContent = on ? "On" : "Off";
831-
label.className = "chaos-status " + (on ? "on" : "off");
829+
toggle.checked = on;
830+
label.textContent = on ? "On" : "Off";
831+
label.className = "chaos-status " + (on ? "on" : "off");
832832
hint.style.display = on ? "block" : "none";
833833
} catch (_) {}
834834
}
835835

836836
document.getElementById("iam-toggle").addEventListener("change", async function () {
837837
try {
838-
await fetch(`${window.location.origin}/_localstack/config`, {
838+
await fetch(`${window.location.origin}/_aws/iam/config`, {
839839
method: "POST",
840840
headers: { "Content-Type": "application/json" },
841-
body: JSON.stringify({ ENFORCE_IAM: this.checked ? "1" : "0" }),
841+
body: JSON.stringify({ state: this.checked ? "ENFORCED" : "ALLOW_ALL" }),
842842
});
843843
await checkIAM();
844844
} catch (e) {

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ replay-dlq: ## Replay messages from the DLQ back to the main queue
8484
# ── IAM enforcement ───────────────────────────────────────────────────────────
8585

8686
iam-enforce: ## Enable IAM policy enforcement — order creation now fails (missing PutItem)
87-
curl -s -X POST http://localhost:4566/_localstack/config \
87+
curl -s -X POST http://localhost:4566/_aws/iam/config \
8888
-H "Content-Type: application/json" \
89-
-d '{"ENFORCE_IAM": "1"}' | python3 -m json.tool
89+
-d '{"state":"ENFORCED"}' | python3 -m json.tool
9090

9191
iam-off: ## Disable IAM enforcement (permissive mode, default)
92-
curl -s -X POST http://localhost:4566/_localstack/config \
92+
curl -s -X POST http://localhost:4566/_aws/iam/config \
9393
-H "Content-Type: application/json" \
94-
-d '{"ENFORCE_IAM": "0"}' | python3 -m json.tool
94+
-d '{"state":"ALLOW_ALL"}' | python3 -m json.tool
9595

9696
iam-fix: ## Grant missing dynamodb:PutItem to the Lambda role — fixes order creation
9797
awslocal iam put-role-policy \
@@ -102,8 +102,7 @@ iam-fix: ## Grant missing dynamodb:PutItem to the Lambda role — fixes order cr
102102

103103
iam-status: ## Show current IAM enforcement state and Lambda role policies
104104
@echo "=== IAM enforcement ===" && \
105-
curl -s http://localhost:4566/_localstack/config | \
106-
python3 -c "import sys,json; c=json.load(sys.stdin); print('ENFORCE_IAM:', c.get('ENFORCE_IAM', False))"
105+
curl -s http://localhost:4566/_aws/iam/config | python3 -m json.tool
107106
@echo "=== Lambda role policies ===" && \
108107
awslocal iam list-role-policies --role-name lambda-exec-role
109108

0 commit comments

Comments
 (0)