A company runs a cron job on an Amazon EC2 instance on a schedule. The cron job invokes a bash script that encrypts a 2 KB file. A customer managed AWS Key Management Service (AWS KMS) key and policy are configured, and the EC2 instance role has the required permissions. Which process should the bash script use to encrypt the file?
Choose an answer
Tap an option to check your answer.
Correct answer: Use the aws kms encrypt command to encrypt the file directly with the existing KMS key..
Why this is the answer
The aws kms encrypt command can directly encrypt data up to 4 KB. Since the file is 2 KB, it falls within this limit, making direct encryption the most straightforward and efficient method. The EC2 instance role already has the necessary permissions, and a customer managed key is configured. Using aws kms create-grant is incorrect because grants are for delegating permissions, not for encrypting data. Generating a data key with aws kms encrypt is not the correct command for data key generation; generate-data-key is. Using a plaintext data key to encrypt the file is insecure because the plaintext key would be exposed. Encrypting a file with an encrypted (ciphertext) data key is impossible; the data key must be decrypted first to be used for encryption. The correct process for larger files would involve generate-data-key to get a plaintext data key for local encryption and an encrypted data key for storage, but for 2KB, direct encryption is best.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed