S3 now encrypts every new object with SSE-S3 by default. Some organizations still require clients to explicitly request encryption, so that an upload without the header is rejected. You can enforce this with a bucket policy on the s3:x-amz-server-side-encryption condition key.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RequireSSES3",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::<your-bucket-name>/*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
}
}
]
}

echo "123456789abcdefg" > textfile
aws s3api put-object --key text01 --body textfile --bucket $bucket
aws s3api put-object --key text01 --body textfile --server-side-encryption AES256 --bucket $bucket
The first upload fails with AccessDenied … with an explicit deny in a resource-based policy; the second one succeeds and returns "ServerSideEncryption": "AES256".
