Amazon S3 supports both server-side encryption (with 3 key management options: SSE-KMS, SSE-C, SSE-S3) and client-side encryption for data uploads. Amazon S3 provides flexible security features to prevent unauthorized users from accessing your data. You can connect to S3 resources from Amazon Virtual Private Cloud (Amazon VPC) using the VPC endpoint

In this section, we create S3 Bucket Policy to require encryption of data at rest.
Similar to the previous lab, we access AWS Management Console

In the S3 interface

In the sid-security-xxxxxxx bucket interface
Select Permission
In Bucket policy, select Edit

{
"Statement": [
{
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::BUCKET_NAME/*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
}
}
]
}


cd ~
echo "123456789abcdefg" > textfile

aws s3api put-object --key text01 --body textfile --profile user1 --bucket ${bucket}
The request will fail because the object is not encrypted.

aws s3api put-object --key text01 --body textfile --server-side-encryption AES256 --profile user1 --bucket ${bucket}
The command was successful because the PUT used SSE-S3.

