DynamoDB Block Public Access toggle and resource-based policy interaction
0 reputation · 08 Jan 2020, 07:18 UTC
0 reputation · 08 Jan 2020, 07:18 UTC
DynamoDB supports resource-based policies that allow administrators to define access permissions directly on a table. When a policy uses a wildcard principal ("*"), the table may be exposed to public access.
The AWS Management Console provides a Block Public Access toggle designed to mitigate accidental exposure. However, there is uncertainty regarding the functional scope of this toggle when interacting with resource-based policies versus identity-based IAM policies.
Specifically, it is unclear if the Block Public Access setting acts as a guardrail that overrides existing resource-based allow statements or if it merely serves as a notification mechanism.
"*"?34775 reputation · 08 Jan 2020, 08:10 UTC
When Block Public Access is enabled for a DynamoDB table, the service inserts a built‑in deny‑all rule that applies to any request that does not carry an authenticated IAM principal. If a resource‑based policy contains "Principal": "*", that policy will not allow anonymous access while the toggle is on. In other words, the toggle actively blocks requests from anonymous principals and takes precedence over the policy’s allow statement.
Because the toggle is the earliest guardrail, it effectively masks any Principal": "*" allow that would otherwise expose the table to the public.
Below is a minimal, safe workflow you can run from an environment that has no IAM role attached (e.g., a fresh EC2 instance or a local machine without configured credentials).
# Enable Block Public Access for a table named MyTable
aws dynamodb update-public-access \
--resource-type TABLE \
--resource-arn arn:aws:dynamodb:us-east-1:123456789012:table/MyTable \
--block-public-access true
# Attach a permissive resource policy (allowing "*")
aws dynamodb put-item \
--table-name MyTable \
--item '{"PK":{"S":"Test"},"Data":{"S":"value"}}'
# Create a resource policy that allows all principals
aws dynamodb put-table-policy \
--table-name MyTable \
--policy-name PublicPolicy \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "dynamodb:*",
"Resource": "arn:aws:dynamodb:us-east-1:123456789012:table/MyTable"
}
]
}'
# Attempt a GetItem without credentials – should fail
aws dynamodb get-item \
--table-name MyTable \
--key '{"PK":{"S":"Test"}}'
The last command will return an AccessDeniedException. If you disable the toggle:
aws dynamodb update-public-access \
--resource-type TABLE \
--resource-arn arn:aws:dynamodb:us-east-1:123456789012:table/MyTable \
--block-public-access false
and re‑run the get-item, the request succeeds, confirming the toggle’s precedence.
If you are seeing unexpected access for unauthenticated clients even after enabling Block Public Access, verify that:
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.