Allows encryption with a specific KMS key only when performed through an approved deployment pipeline role.
What this SCP does
This Service Control Policy (SCP) restricts KMS key encryption operations to only be performed through an approved deployment pipeline role by denying access to all other principals. This ensures encryption operations are performed only through secure, approved channels.
By using a deny-based policy with an exception for the deployment pipeline role, this SCP follows AWS best practices for SCPs while implementing the principle of least privilege for encryption operations. This ensures that sensitive data can only be encrypted through approved, automated processes rather than by individual users.
How to test this SCP works
To validate this SCP, test encryption operations with different roles against a specific KMS key.
For thorough testing, create a test KMS key, configure the SCP with the specific key ARN and deployment role ARN, and then test encryption operations from multiple different roles. The SCP should deny encryption attempts from all roles except the specified DeployPipelineRole.