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.
More on IAM Best Practices
What does least privilege look like in practice, not in theory?BeginnerWhat are the IAM rules you enforce for humans?BeginnerHow do you design Identity Center permission sets for many teams?IntermediateHow does ABAC with Identity Center work, and when is it worth it?AdvancedWhen do you use permission boundaries in production?IntermediateHow do you remove long-lived access keys from an existing estate?Intermediate