Interview Prep/AWS/S3, EBS and EFS

`aws s3 cp` gets `An error occurred (AccessDenied) when calling the GetObject operation` but the IAM policy allows `s3:GetObject` and the bucket policy is fine.

IntermediateTroubleshootingS3, EBS and EFS
Answer

Likely causes → The object is encrypted with SSE-KMS using a customer managed key, and the caller has no kms:Decrypt on that key (through the key policy or IAM). For uploads, the missing permission is kms:GenerateDataKey.

Diagnose →

aws s3api head-object --bucket data --key reports/q3.parquet \
  --query '[ServerSideEncryption,SSEKMSKeyId]'
aws kms get-key-policy --key-id <key-arn> --policy-name default --output text
# CloudTrail: look for kms Decrypt with errorCode AccessDenied

Fix →

  1. Grant kms:Decrypt on the key ARN to the role in IAM, and make sure the key policy allows IAM policies (the root principal statement) or names the role
  2. For cross-account access, both the key policy and the caller's IAM policy must allow it

Prevent → Every S3 access policy template includes the matching KMS statement, and S3 Bucket Keys are on to reduce KMS calls.

aws All AWS questions Roadmap: AWS core services

More on S3, EBS and EFS