Encrypt the 2 KB file directly with the aws kms encrypt command
A company runs a cron job on an Amazon EC2 instance on a predefined schedule. The cron job calls a bash script that encrypts a 2 KB file. A security engineer creates an AWS Key Management Service (AWS KMS) customer managed key with a key policy. The key policy and the EC2 instance role have the necessary configuration for this job. Which process should the bash script use to encrypt the file?
Community Votes
56% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
KMS Encrypt operates on plaintext up to 4 KB, so a 2 KB payload fits without generating a data key. For this small, single-file, scheduled job the direct Encrypt call is the simplest valid process; envelope encryption (generate-data-key) is preferred at scale but is not required here, and option D's wording (encrypt with the encrypted data key) is itself incorrect—you encrypt with the plaintext data key.
A cron job encrypts a small 2 KB file using a configured KMS customer managed key. The AWS KMS Encrypt API accepts plaintext up to 4,096 bytes, so a 2 KB file is within the limit and can be encrypted directly with aws kms encrypt using the existing key, with no need for a data key, grant, or envelope-encryption machinery.
Choosing option D, which describes encrypting the file with the encrypted data key—that is wrong; you must use the plaintext data key to encrypt and store the encrypted data key alongside. For a 2 KB file, direct `aws kms encrypt` (option A) is both valid and simpler.
Community Discussion (5 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The file is 2 KB, well under the 4 KB ceiling of the KMS Encrypt API, and the key policy plus instance role are already configured for the job. The bash script can callaws kms encrypt with the existing CMK to encrypt the file directly, which is the correct and simplest process for a small payload.