- Newest
- Most votes
- Most comments
=>To publish an AWS Serverless Application from Visual Studio while complying with an S3 encryption policy, follow these steps:
Enable Default Encryption on S3 Bucket:
=>Go to the S3 console. Select your bucket. Go to "Properties" > "Default encryption". Enable default encryption and choose "AES-256" or "AWS-KMS". Save changes. Use the Encrypted S3 Bucket in Visual Studio:
=>When publishing from Visual Studio, specify the S3 bucket with default encryption enabled. Manual Upload with Encryption (if needed):
Upload artifacts manually with encryption:
aws s3 cp path/to/your-artifact.zip s3://your-bucket-name/your-artifact.zip --sse AES256
with AWS KMS
aws s3 cp path/to/your-artifact.zip s3://your-bucket-name/your-artifact.zip --sse aws:kms --sse-kms-key-id your-kms-key-id
Update CloudFormation Template:
=>Reference the manually uploaded S3 artifact in your serverless.template or template.yaml.

Thanks for the reply Mahankali. I will try this. Just to be clear, the Default Encryption is already enabled currently, but it is using "Server-side encryption with Amazon S3 managed keys (SSE-S3)"
I have now tried to change the bucket default encryption to SSE-KMS and tried the publish from VS again. It failed with the same error message. I am not familiar with the serverless.template and how to configure it to use a manually uploaded artifacts. That said, I do not want to manually upload artifacts with each publish, I should just be able to Click on publish, and be done with it. For Info, when I remove the SCP policy to deny S3 putObject when not encrypted, everything works fine. I might just leave this policy option disabled for now.