aws s3api put-bucket-encryption cli command adds extra quotes when in cmd

Viewed 22

When I use the the following command in cmd to add bucket encryption to a certain bucket in my account there is additions quotes that show up and the command never really works. Other s3api command are working just fine.

Command I type:

aws s3api put-bucket-encryption --bucket MyBucket --server-side-encryption-configuration '{"Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}}]}'

What happens when I hit enter:

> aws s3api put-bucket-encryption --bucket MyBucket --server-side-encryption-configuration ''"'"'{Rules:' '[{ApplyServerSideEncryptionByDefault:' '{SSEAlgorithm:' 'AES256}}]}'"'"''

Any ideas what I am doing wrong in the AWScli?

Eventually once I have the command right I want to code it into my c# program but that will be another question.

1 Answers

For the record: Problem can be solved by escaping double quotes with backslash in JSON section:

aws s3api put-bucket-encryption --bucket MyBucket --server-side-encryption-configuration '{\"Rules\": [{\"ApplyServerSideEncryptionByDefault\": {\"SSEAlgorithm\": \"AES256\"}}]}'
Related