Indi
Indi

Reputation: 429

How to upload a directory to a AWS S3 bucket along with a KMS ID through CLI?

I want to upload a directory (A folder consist of other folders and .txt files) to a folder(partition) in a specific S3 bucket along with a given KMS-id via CLI. The following command which is to upload a jar file to an S3 bucket, was found.

The command I found for upload a jar:

aws s3 sync /?? s3://???-??-dev-us-east-2-813426848798/build/tmp/snapshot --sse aws:kms --sse-kms-key-id alias/nbs/dev/data --delete --region us-east-2 --exclude "*" --include "*.?????"

Suppose;

Location (Bucket Name with folder name) - "s3://abc-app-us-east-2-12345678/tmp"

KMS-id - https://us-east-2.console.aws.amazon.com/kms/home?region=us-east-2#/kms/keys/aa11-123aa-45/

Directory to be uploaded - myDirectory

And I want to know;

  1. Whether the same command can be used to upload a directory with a bunch of files and folders in it?
  2. If so, how this command should be changed?

Upvotes: 1

Views: 1508

Answers (1)

Arun Kamalanathan
Arun Kamalanathan

Reputation: 8603

the cp command works this way:

aws s3 cp ./localFolder s3://awsexamplebucket/abc --recursive --sse aws:kms --sse-kms-key-id a1b2c3d4-e5f6-7890-g1h2-123456789abc

I haven't tried sync command with kms, but the way you use sync is,

aws s3 sync ./localFolder s3://awsexamplebucket/remotefolder 

Upvotes: 2

Related Questions