Provider-Specific Security and IAM
What you'll learn: How AWS Lambda execution roles, Azure managed identities, and GCP service accounts control what your serverless functions can access.
The Core Concept
Serverless functions need permission to interact with other cloud services—reading from storage, writing to databases, or calling APIs. Each provider implements identity and access management (IAM) differently, giving functions credentials that define what they can and cannot do.
Think of it like employee badges: the function is the employee, and its IAM identity is the badge that grants access to specific rooms (cloud resources). Each cloud provider issues different "badge types."
AWS Lambda Execution Roles
Lambda uses IAM roles that you attach to your function. The role defines permissions through policies:
- The function assumes this role when it runs
- Policies grant specific permissions (e.g.,
s3:GetObjectto read from S3) - Best practice: Follow least privilege—only grant necessary permissions
Azure Managed Identities
Azure Functions use managed identities (system-assigned or user-assigned):
- System-assigned: automatically created and tied to the function's lifecycle
- User-assigned: shared across multiple functions
- No credential management required—Azure handles it automatically
- Best practice: Use system-assigned for single-function access, user-assigned for shared scenarios
GCP Service Accounts
Cloud Functions use service accounts as their identity:
- Default service account or custom service accounts
- Permissions granted through IAM bindings
- Service accounts can be shared or function-specific
- Best practice: Create dedicated service accounts per function or workload
Common Security Best Practices
- Least privilege: Grant only necessary permissions
- Avoid hardcoded credentials: Use provider IAM mechanisms
- Rotate credentials: For any external system access
- Audit permissions: Regularly review what functions can access
Key Takeaway: Each cloud provider offers native IAM solutions—AWS execution roles, Azure managed identities, and GCP service accounts—that securely grant functions access to resources without embedding credentials in code.