This template creates an S3 bucket and an object within it, encrypting the object with a specified AWS KMS key.

Terraform Template

resource "aws_kms_key" "examplekms" {
  deletion_window_in_days = 7
  description = "KMS key 1"
}

resource "aws_s3_bucket" "examplebucket" {
  bucket = "examplebuckettftest"
}

resource "aws_s3_bucket_acl" "example" {
  acl = "private"
  bucket = aws_s3_bucket.examplebucket.id
}

resource "aws_s3_object" "example" {
  bucket = aws_s3_bucket.examplebucket.id
  key = "someobject"
  kms_key_id = aws_kms_key.examplekms.arn
  source = "index.html"
}