Ensure that the IAM execution role associated with each Amazon Lambda function is using AWS-managed policies instead of customer-managed or inline policies in order to enhance security by implementing the Principle of Least Privilege (POLP) and ensure consistency.
excellence
A Lambda function's execution role is an AWS Identity and Access Management (IAM) role that grants the function permission to access specific AWS services and resources. For example, you can attach an execution role for development purposes that has permission to send logs to Amazon CloudWatch Logs, to upload trace data to AWS X-Ray, or to read events from an Amazon Kinesis data stream or consumer. Using AWS-managed policies for IAM execution roles ensures security by granting minimum necessary permissions through expert-curated policies. This minimizes risks, simplifies management, and maintains compliance with evolving AWS cloud services.
Audit
To determine if the IAM execution roles associated with Lambda functions are using AWS-managed policies, perform the following actions:
Remediation / Resolution
To ensure that the IAM execution role associated with your Amazon Lambda functions is using AWS-managed policies only, perform the following actions:
The following AWS-managed policies are designed and tested by AWS and provide the permissions required to use all the Amazon Lambda features:
- "AWSLambdaBasicExecutionRole" – permission to upload logs to Amazon CloudWatch Logs.
- "AWSLambdaDynamoDBExecutionRole" – permission to read records from an Amazon DynamoDB stream.
- "AWSLambdaKinesisExecutionRole" – permission to read events from an Amazon Kinesis data stream or consumer.
- "AWSLambdaMQExecutionRole" – permission to read records from an Amazon MQ broker.
- "AWSLambdaMSKExecutionRole" – permission to read records from an Amazon Managed Streaming for Apache Kafka (Amazon MSK) cluster.
- "AWSLambdaSQSQueueExecutionRole" – permission to read a message from an Amazon Simple Queue Service (Amazon SQS) queue.
- "AWSLambdaVPCAccessExecutionRole" – permission to manage elastic network interfaces to connect your function to a virtual private cloud (VPC).
- "AWSXRayDaemonWriteAccess" – permission to upload trace data to X-Ray.
- "CloudWatchLambdaInsightsExecutionRolePolicy" – permission to write runtime metrics to CloudWatch Lambda Insights.
- "AmazonS3ObjectLambdaExecutionRolePolicy" – permission to interact with Amazon S3 object Lambda and to write to CloudWatch Logs.
References
- AWS Documentation
- Lambda resource access permissions
- Lambda execution role
- Identity-based IAM policies for Lambda
- Configuring Lambda function options
- AWS Command Line Interface (CLI) Documentation
- list-functions
- get-function
- list-attached-role-policies
- list-role-policies
- detach-role-policy
- delete-role-policy
- attach-role-policy