Interview Prep/AWS/IAM Best Practices

What is the right way to give a Lambda or ECS task access to a KMS-encrypted resource?

IntermediateProductionIAM Best Practices
Answer

Both the IAM role policy and the KMS key policy must allow it (unless the key policy delegates to IAM with the standard "Enable IAM User Permissions" statement for the account). Grant only kms:Decrypt (and kms:GenerateDataKey if it writes), and constrain with kms:ViaService (for example s3.eu-west-1.amazonaws.com) and encryption context so the role cannot use the key directly for anything else.

aws All AWS questions Roadmap: AWS core services

More on IAM Best Practices