I've got an AWS key generated and an S3 file which I wanted to encrypt server-side. I don't understand why one of the users can decrypt it though. The setup I've got is:
Key with 3 policy statements:
arn:aws:iam::${AWS::AccountId}:root
with access tokms:*
arn:aws:iam::${AWS::AccountId}:user/bank_trans_admin
with access tokms:Encrypt
andkms:DescribeKey
- Instance profile with access to
kms:Decrypt
andkms:DescribeKey
I'm using aws-vault
with the bank_trans_admin
configured. Using that, I uploaded some file, which worked as expected:
aws-vault exec bank_trans_admin -- aws s3 cp --sse aws:kms --sse-kms-key-id alias/TransactionAccountsKey the_file s3://some-bucket/
I verified in the AWS web console that the file is encrypted using KMS/sse.
But now I wanted to make sure I can't use decryption on the same account, so I did:
aws-vault exec bank_trans_admin -- aws s3 cp --sse aws:kms --sse-kms-key-id alias/TransactionAccountsKey s3://some-bucket/the_file the_file
and it worked! I expected to be denied access, since I allowed only Encrypt
for this IAM user. What am I missing here?