bug: Non-existent KMS key does not return an error when passed through S3 copyObject and putObject
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
copyObject and putObject (and perhaps other requests) requests are accepted and do not return an error when an SSE KMS key is specified.
Expected Behavior
The error which should be returned is KMS.NotFoundException.
How are you starting LocalStack?
Custom (please describe below)
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)
Localstack testcontainers
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
Call copyObject/putObject via latest version using AWS SDK V2 and specific a ssekmsKeyId.
final var copyObjectRequestBuilder =
CopyObjectRequest.builder()
.serverSideEncryption(ServerSideEncryption.AWS_KMS)
.ssekmsKeyId("NON-EXISTENT KMS KEY")
.sourceBucket(sourceBucketName)
.sourceKey(sourceKey)
.destinationBucket(destinationBucket)
.destinationKey(destinationKey);
final var copyObjectResponse = sourceRegionS3Client.copyObject(copyObjectRequest); // Error should be thrown here but localstack does not return an error
Environment
- OS: MacOS 13.0
- LocalStack: Latest (v1.2.0)
Anything else?
No response
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our developer guide.
Hi @kdelalic and thanks for your report!
This feature has been added with #7448, however it will only be available with the new implementation of S3 that we have been working on, available under a feature flag. You can use this new implementation with PROVIDER_OVERRIDE_S3=asf (for configuration of LocalStack, you can see here). An additional feature flag for the specific validation of the KMS key needs to be set as well, to not introduce a breaking change: S3_SKIP_KMS_KEY_VALIDATION=0.
You can give a try by pulling the latest image of localstack. Thank you!