A SysOps administrator has configured an Amazon EC2 instance to upload files to an Amazon S3 bucket. The bucket is encrypted using a customer managed key (CMK) in AWS Key Management Service (AWS KMS). The administrator has attached an IAM policy to the EC2 instance's IAM role that grants 's3:PutObject' permission. However, when the application on the EC2 instance attempts to write to the S3 bucket, it receives an Access Denied error. Which configuration change will resolve this issue?
- Update the KMS key policy to allow the EC2 instance's IAM role permissions for the 'kms:GenerateDataKey' and 'kms:Decrypt' actions.Cevap
- BAttach an IAM policy to the EC2 instance's IAM role that grants the 'kms:GenerateDataKey' and 'kms:Decrypt' permissions without modifying the KMS key policy.
- CAdd the 'iam:PassRole' permission to the EC2 instance's IAM role to allow the S3 service to assume the role and access the KMS key.
- DConfigure an Amazon S3 Gateway VPC Endpoint in the VPC and associate it with the subnet's route table.
Cevap
Update the KMS key policy to allow the EC2 instance's IAM role permissions for the 'kms:GenerateDataKey' and 'kms:Decrypt' actions.
The correct answer is to update the KMS key policy to allow the EC2 instance's IAM role permissions for the 'kms:GenerateDataKey' and 'kms:Decrypt' actions. When writing to an S3 bucket encrypted with a customer managed key, the client must request a data key from KMS to encrypt the object before uploading it. Therefore, the IAM role needs KMS permissions, and because KMS key policies are the primary authority for key access, the KMS key policy must be updated to allow the IAM role to perform these actions.
Adım Adım Çözüm
Anahtar Kavram
KMS key policies take precedence over IAM policies, and accessing a KMS-encrypted S3 bucket requires both S3 and KMS permissions.