How to Stop Objects from Being Upload to Amazon S3 Without Encryption using Bucket Policies
Tags: aws, s3bucketpolicy, encryption, saac03
Published: 2023-12-20 13:42:31

---
title: How to Stop Objects from Being Upload to Amazon S3 Without Encryption using Bucket Policies

published: true
description: 
tags: aws,s3bucketpolicy,encryption,SAAC03
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-11-19 05:28 +0000
---

To prevent uploads of unencrypted objects to Amazon S3, you can enforce encryption at the bucket level or use bucket policies to require server-side encryption. Amazon S3 provides several options for server-side encryption, including Amazon S3 managed keys (SSE-S3), AWS Key Management Service (AWS KMS) keys (SSE-KMS), and customer-provided keys (SSE-C). Here are steps you can take to enforce encryption.

#### In this article we are going to learn how to do this using Bucket Policies.

### Step 1:
Go to your S3 Console & Choose or create a Bucket

![S3 Conosle](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmq18og23luj8wirndym.png)

### Step 2:
Now to go the permission tab and scroll down and choose 

![S3 Bucket](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nm1e8da6wl4bsfln7za6.png)

Now Click on Policy generator

![Bucket Policy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jc7esu5emydzxdk0f9tc.png)




Now go back policy page and copy the bucket ARN (We Need This Later)

![bucket ARN](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p519afk4jmkup8ofq1wn.png)


### Step 3: Config Bucket Policy

![Bucket Policy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sp2jnz72crvwod3268d0.png)

Now Click add Statement & Click Generate Policy


![Generate Policy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bdj2yv780movb7vtg5e.png)

### Now Copy the JSON and past it to bucket policy box

![Policy JSON](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gwsnbs52ekn0oey3u4l.png)

In the Resource Line Just add ' /* ' and click save changes. This Means Every Objects in this Bucket.

![policy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/is7zgmq36xjr7e0n05dw.png)


![save changes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ejjsgfuio5f6haj9z88.png)

![save sucessfull](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2drjy5yuemb3tly4xj62.png)

Now go back Object Tab and upload some files. The upload will failed unless you choose Encryption Options. 


![upload failed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bw3nd9s2adkt020l7cat.png)


### Before
![Unencrypted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4sv83x4s0fsiqhxe2246.gif)

### After
![encrypted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jixv66fhm6ork8921p92.gif)

### Conclusion:
Securing your S3 bucket against unencrypted file uploads is a proactive step towards maintaining the integrity and confidentiality of your data. By following the guidelines outlined in this post, you'll be equipped with the knowledge to establish a robust security framework for your AWS S3 bucket. Stay ahead of potential threats and safeguard your data with these essential practices.