A checklist for S3 AccessDenied errors in the order AWS evaluates them: the identity making the call, its IAM policy, the bucket policy, KMS keys, organization policies, and the missing-object case that also returns 403.

AccessDenied is the least helpful error S3 returns, because the same 403 covers a missing permission, an explicit deny, a KMS key you cannot use and an object that does not exist. Guessing at policies wastes hours.
AWS evaluates a request in a fixed order, so it pays to check in that order too. This guide walks through each layer with the commands that confirm or rule it out, plus the fix for each cause.
For requests within the same account or organization, S3 returns enhanced access denied messages. The message tells you whether a policy denied explicitly or implicitly and which kind of policy it was:
User: arn:aws:sts::123456789012:assumed-role/reports-api/i-0abc is not authorized to perform: s3:GetObject on resource: "arn:aws:s3:::acme-reports/2026/11/q3.pdf" because no identity-based policy allows the s3:GetObject action
"No identity-based policy allows" points at the role's IAM policy. "With an explicit deny in a resource-based policy" points at the bucket policy. Cross-organization calls only get a bare Access Denied, which is when the rest of this checklist matters most.
This small Go program prints the identity the SDK resolves and the exact code and message S3 returns:
package main
import (
"context"
"errors"
"fmt"
"log"
"os"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/sts"
"github.com/aws/smithy-go"
)
func main() {
ctx := context.Background()
bucket, key := os.Args[1], os.Args[2]
cfg, err := config.LoadDefaultConfig(ctx)
if err != nil {
log.Fatal(err)
}
// 1. Which identity is the SDK actually using?
id, err := sts.NewFromConfig(cfg).GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{})
if err != nil {
log.Fatal(err)
}
fmt.Println("caller:", aws.ToString(id.Arn))
// 2. Try the request and print the error code and message S3 returned.
_, err = s3.NewFromConfig(cfg).GetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
})
var apiErr smithy.APIError
if errors.As(err, &apiErr) {
fmt.Printf("code=%s message=%q\n", apiErr.ErrorCode(), apiErr.ErrorMessage())
return
}
if err != nil {
log.Fatal(err)
}
fmt.Println("ok")
}
Start with the principal, because a correct policy attached to the wrong role still fails. The SDK resolves credentials from environment variables, then shared config and profiles, then container or instance roles, so a stale AWS_ACCESS_KEY_ID in a shell or CI job silently overrides the role you configured. Run aws sts get-caller-identity in the same environment as the failing code, or the Go program above, and compare the ARN with the principal your policies name.
S3 actions apply to two different resources: s3:ListBucket applies to the bucket ARN, while s3:GetObject, s3:PutObject and s3:DeleteObject apply to object ARNs with /*. A policy that lists only one of them produces exactly the "list works, get fails" pattern:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::acme-reports"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::acme-reports/*"
}
]
}
Check for permissions boundaries on the role too, since a boundary that does not allow s3:* actions caps the policy even when the policy itself is correct.
An explicit Deny wins over every Allow in IAM policy evaluation. Bucket policies often carry guardrails that deny by condition: aws:SecureTransport set to false rejects plain HTTP, aws:SourceVpce rejects anything that does not arrive through a specific VPC endpoint, and s3:x-amz-server-side-encryption conditions reject uploads without the expected encryption header. Read the policy with aws s3api get-bucket-policy --bucket acme-reports and check each Deny against the failing request.
For cross-account access, both sides must allow it: the caller's identity policy and the bucket policy naming the caller's account or role. Block Public Access only affects public grants, so it is the cause when an anonymous request or a public bucket policy stops working, not for role-based access.
Objects written with SSE-KMS need permissions on the key as well as the bucket. Reading needs kms:Decrypt, and writing needs kms:GenerateDataKey, granted in the role's policy and allowed by the key policy. The SSE-KMS docs cover the details. The symptom is a 403 on some objects but not others, when only part of the bucket was written with that key. aws s3api head-object shows ServerSideEncryption and SSEKMSKeyId for an object if you can read its metadata.
Service control policies and resource control policies in AWS Organizations can deny S3 actions for every role in an account, often by Region. VPC endpoint policies can restrict which buckets are reachable through a gateway endpoint, so a bucket outside the allowed list fails only from inside the VPC. The enhanced error message names both cases when the request stays within the organization.
GetObject returns 404 for a missing key only when the caller has s3:ListBucket. Without it, S3 returns 403 so it does not reveal which keys exist. Check for a leading slash, URL-encoded characters or a wrong prefix in the key before rewriting policies. Presigned URLs fail the same way, and they also return 403 after expiry or when the identity that signed them has lost access.
A hand-written policy drifts as soon as the code starts using an operation the policy does not list. Encore is a backend framework with built-in infrastructure, where a bucket is declared in code. Encore provisions an IAM role for the service, or a service account on GCP.

Run in your terminal to get started locally.
// reports/reports.go
package reports
import (
"context"
"errors"
"time"
"encore.dev/beta/auth"
"encore.dev/beta/errs"
"encore.dev/storage/objects"
)
// The bucket is declared in code. Encore creates it and grants this
// service the operations the code uses.
var Reports = objects.NewBucket("reports", objects.BucketConfig{})
type SaveParams struct {
Key string `json:"key"`
Body string `json:"body"`
}
//encore:api private method=POST path=/reports
func Save(ctx context.Context, p *SaveParams) error {
w := Reports.Upload(ctx, p.Key)
if _, err := w.Write([]byte(p.Body)); err != nil {
w.Abort(err)
return err
}
return w.Close()
}
type LinkResponse struct {
URL string `json:"url"`
}
// Link signs a download URL for a report the caller owns. The object key is
// derived from the authenticated user, not taken as a raw bucket path.
//
//encore:api auth method=GET path=/reports/:id/link
func Link(ctx context.Context, id string) (*LinkResponse, error) {
uid, _ := auth.UserID()
key := "reports/" + string(uid) + "/" + id
if _, err := Reports.Attrs(ctx, key); errors.Is(err, objects.ErrObjectNotFound) {
return nil, &errs.Error{Code: errs.NotFound, Message: "no such report"}
} else if err != nil {
return nil, err
}
u, err := Reports.SignedDownloadURL(ctx, key, objects.WithTTL(15*time.Minute))
if err != nil {
return nil, err
}
return &LinkResponse{URL: u.URL}, nil
}
Link uses the auth access level, so the app needs an auth handler. The object key is built from the authenticated user ID and the report ID, so a caller cannot mint a URL for another user's object.
Each bucket is declared in code, and Encore provisions an IAM role for the service, or a service account on GCP, so you do not write a policy by hand. A missing object comes back as objects.ErrObjectNotFound, not an ambiguous 403.
encore run serves the bucket from local storage, so the same code can be tested against Encore's local emulation. On deploy to AWS, Encore creates the S3 bucket in your own account, and Encore provisions an IAM role for the service, or a service account on GCP. The same code targets GCS on GCP.
When a coding agent adds an upload path, the permission change lands in the same diff as the code that needs it, with no policy JSON to keep in sync and no 403 to debug after deploy.
Best fit: Go and TypeScript teams that keep hitting S3 403s from policies drifting away from the code, and want the bucket declared next to the code that uses it.
If the caller does not have s3:ListBucket on the bucket, S3 returns 403 Access Denied for a key that does not exist, so it does not reveal which keys exist. Grant s3:ListBucket on the bucket ARN and the same request returns 404 Not Found.
The usual causes are a resource ARN that names the bucket instead of the objects (it needs arn:aws:s3:::bucket/*), an explicit Deny in the bucket policy, an SSE-KMS key the role cannot decrypt with, or a service control policy or VPC endpoint policy that denies the call. An explicit Deny anywhere wins over any Allow.
For requests within the same account or AWS Organization, the AccessDenied message names the policy type, such as an identity-based policy, a resource-based policy or a service control policy, and includes the policy ARN for explicit denies. CloudTrail records the same context. Cross-organization requests only get a generic message.
Yes. Encore provisions an IAM role for the service, or a service account on GCP, so you do not write the policy by hand. Infrastructure-as-code tools such as Terraform can also manage the policies, but you write the statements yourself.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.