Lambda Function Protection
Policy Description
What this SCP does
This Service Control Policy (SCP) prevents unauthorized deletion or modification of Lambda functions, ensuring that critical application components remain intact. This is important for maintaining serverless application reliability.
By restricting changes to Lambda functions with the "Prod-" prefix to only users with the Operations department tag, this policy creates a separation of duties that protects production serverless workloads from unauthorized or accidental modifications, while still allowing flexibility for non-production environments.
Validation Strategy
How to test this SCP works
To validate this SCP, try to create and modify Lambda functions with different naming patterns and roles.
- Valid test: Create Lambda functions with both "Prod-" and other prefixes
- Valid test: Create IAM roles with and without the Operations department tag
- Expected result: Updates to "Prod-" prefixed functions should succeed when performed by roles tagged with Department=Operations, but fail for other roles, while updates to non-"Prod-" functions should succeed for all roles
This testing approach confirms that only properly tagged roles can modify production Lambda functions, while all other principals are prevented from changing these critical serverless resources.
SCP Policy & Validation Scenarios
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyLambdaFunctionModification",
"Effect": "Deny",
"Action": [
"lambda:DeleteFunction",
"lambda:UpdateFunctionCode",
"lambda:UpdateFunctionConfiguration"
],
"Resource": "arn:aws:lambda:*:*:function:Prod-*",
"Condition": {
"StringNotEquals": {
"aws:PrincipalTag/Department": "Operations"
}
}
}
]
}