Last time I wrote about encrypting EBS boot volumes, this week I will continue with the encryption as the main topic by writing about S3 encryption and since it could not have turned out any other way, we will use again KMS for that.
Files in S3 also can be encrypted by using KMS, providing an extra layer of security.
In the example I will use to explain it, I will use:
- An EC2 instance
- An IAM role (I will call it “sync”) attached to the EC2 instance
- S3 Bucket (I will call it „encrypted-sync“)
- Key in KMS
Remember that to use roles for applications that run on Amazon EC2 instances instead of AWS credentials is an AWS best practice.
Files in the server will synchronise with S3 every 5 minutes. The files will be encrypted in S3.
As simple as our scenario: Just a command.
s3 --region eu-central-1
--sse aws:kms --sse-kms-key-
Here a small explanation for some parts of the command:
--sse (string) Specifies server-side encryption of the object in S3.
id (string) The AWS KMS key ID that should be used to server-side encrypt the object in S3.
In order that the synchronisation takes place every 5 minutes, you just need to create a cronjob.