S3 Bucket Policies
In this blog, I will walk you through with some of the interesting S3 bucket polices to secure the bucket and objects.
I have a bucket called “demo-aws-sathiya”.
I need the bucket to be accessed from other regions and from outside AWS
(On Prem).
Hence, I created a S3 VPC Interface Endpoint.
To access S3 bucket via VPCE interface endpoint we need to use the DNS name of the S3 VPC Interface Endpoint.
By default, the S3 VPCE
policy allows access to all the buckets in that account.
Let’s start by
implementing a policy at the S3 VPC Interface Endpoint level to restrict access to all buckets except
the required ones.
This allows access to the bucket "demo-aws-sathiya" to be accessed using the S3 VPC interface endpoint.
I get access denied when I try to access others bucket NOT ALLOWED in the policy.
Next, our bucket has empty bucket policy which means it is accessible from outside.
Now,
we need to make sure the bucket is accessed only via S3 VPC Interface
endpoint.
Hence, I am updating the bucket policy.
Lets test it and it is accessible.I get access denied when I try to access the same bucket without using S3 VPC interface endpoint.
Lets add one more layer
to disable HTTP access via S3 interface endpoint to the bucket.
aws:SecureTransport is an AWS global condition key used in S3 bucket policies to deny any request made over HTTP and allow only HTTPS.
Next, Lets update the bucket policy to ensure all the object actions are done using the "AuthType" as "REST-HEADER" -> Request is authenticated using the "Authorization" header (CLI or Programmatic mode)
Finally, lets enforce the object upload to the bucket must specify the encryption type as "AES256".
We are mandating the upload object using SSE-S3 - AES256.
I created a file and uploaded and ended up with ACCESS DENIED.
Lets try the same with -sse flag as AES256 and it worked.
Comments
Post a Comment