An enterprise architecture uses a centralized logging account (Account A) containing an Amazon S3 bucket for security audit logs. The bucket is encrypted using an AWS KMS customer managed key owned by Account A. A security auditing application runs on Amazon EC2 instances in a production account (Account B) and must write compliance reports directly to the S3 bucket in Account A.
Which combination of configuration steps will allow the application to securely write reports to the bucket while adhering to the principle of least privilege?
- Configure the S3 bucket policy in Account A to allow the IAM role of the EC2 instances in Account B to perform the s3:PutObject action. Configure the KMS key policy in Account A to allow the EC2 instances' IAM role to perform the kms:GenerateDataKey action. Attach an identity-based policy to the EC2 instance IAM role in Account B that grants permissions for both actions.Cevap
- BCreate an IAM user in Account A with s3:PutObject and kms:GenerateDataKey permissions. Store the IAM user's Access Key ID and Secret Access Key as plaintext parameters in Systems Manager Parameter Store in Account B, and configure the EC2 instances to retrieve these credentials to authenticate S3 API operations.
- CModify the S3 bucket policy in Account A to allow the root user of Account B to perform the s3:PutObject action. Store the Account B root credentials in Systems Manager Parameter Store in Account B, and configure the EC2 instances to use these credentials to authenticate API calls to the S3 bucket.
- DConfigure the EC2 instance role in Account B with s3:PutObject permissions and configure the S3 bucket policy in Account A to trust Account B. Enable automatic key rotation on the KMS key in Account A to automatically authorize and grant access to the EC2 instance role in Account B without needing to modify the KMS key policy.
Cevap
Configure the S3 bucket policy in Account A to allow the IAM role of the EC2 instances in Account B to perform the s3:PutObject action. Configure the KMS key policy in Account A to allow the EC2 instances' IAM role to perform the kms:GenerateDataKey action. Attach an identity-based policy to the EC2 instance IAM role in Account B that grants permissions for both actions.
For cross-account access where the target S3 bucket is encrypted using a Customer Managed Key, two conditions must be met: both the identity-based policy (in the caller's account) and the resource-based policies (S3 bucket policy and KMS key policy in the target account) must allow the actions. The EC2 instance role in Account B must be granted permissions to perform 's3:PutObject' and 'kms:GenerateDataKey'. Correspondingly, Account A's S3 bucket policy and KMS key policy must trust and allow the EC2 role from Account B to perform these actions.
Adım Adım Çözüm
Anahtar Kavram
Cross-Account IAM and Resource Policy Evaluation with KMS Encryption