Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Least privilege for AWS Lambda and S3 means giving each function only the AWS permissions its code needs, limited to the resources and context where it should operate. Two separate grants are involved: the Lambda execution role governs the function’s calls to AWS services such as S3, while the function’s resource-based policy governs whether S3 may invoke the function.
Which permission controls which direction?
Think of the setup as three distinct permissions, each in a different policy location:
| Purpose | Policy location | Least-privilege scope |
|---|---|---|
| Let Lambda code read or write S3 objects | The execution role’s identity-based permissions policy | Only the S3 actions and bucket or object resources required by the function’s actual work. |
| Let S3 invoke a Lambda function after an event | The Lambda function’s resource-based policy | Allow the S3 service principal for the intended bucket and account, and target the needed function, version, or alias. |
| Let Lambda assume its execution role | The role’s trust policy | Trust the Lambda service principal, lambda.amazonaws.com. |
A trigger permission does not give the function’s code permission to read or write objects. Conversely, permissions on the execution role do not authorize S3 to invoke the function. If a function handles an S3 event and then calls the S3 API, both directions need their own correctly scoped grants. See AWS’s execution role guidance and permissions for services that invoke Lambda.
How should you scope the Lambda execution role?
Build the permissions policy from the operations the code actually performs. A function that retrieves an object, one that uploads a result, and one that lists a bucket have different needs; there is no universal S3 action list that is least-privilege for every function. Match each required action to the narrowest resource ARN that supports the operation, and add conditions where they correctly constrain access.
#1 Best Overall
- Inventory the function’s work. Identify the S3 API operations used on each code path, including error handling and less-frequent tasks. Do not grant permissions just because another Lambda function uses them.
- Map operations to resources. Scope permissions to the necessary bucket or object resources rather than granting broad access to unrelated buckets or all S3 resources. The exact ARNs depend on what the code does.
- Review observed use, then refine. AWS IAM Access Analyzer can use CloudTrail activity over a selected period to generate a policy template. Treat observed activity as evidence, not proof of every permission needed: a function can only exercise code paths that ran during that period. AWS recommends reducing the policy to required permissions before production; see Lambda execution roles and IAM Access Analyzer policy generation.
How do you let S3 invoke Lambda securely?
Put the trigger grant in the function’s resource-based policy. For an S3 event source, scope the grant to the intended bucket with aws:SourceArn and include aws:SourceAccount. AWS notes that a bucket ARN does not contain an account ID. The account condition helps protect against a bucket being deleted and later recreated by a different account under the same name. See AWS’s service invocation guidance.
For fine-grained control, AWS recommends full JSON resource-based policies. Before using put-resource-policy, retrieve and inspect the current policy: that command replaces the existing resource-based policy, so an unreviewed update can remove permissions already in place. Details are in the Lambda resource-based policy documentation.
Rank #2
Why give each function its own role?
Separate roles let you tailor permissions to separate jobs. With a shared role, every function that can assume it may have access to the full set of permissions attached to it, even if only one function needs some of them. AWS’s Lambda security whitepaper recommends a unique role for each function, configured with the minimum permissions it needs. See the AWS Lambda security best practices.
How can an S3 trigger create a loop?
If a function writes objects to the same bucket that triggers it for uploads, those writes may trigger the function again. Avoid the cycle by using separate buckets for input and output, or by limiting the event notification to an incoming prefix that excludes the function’s output. AWS describes these approaches in its S3 and Lambda configuration guidance.
Free tools Windows power users keep installed
One-click scans. No signup required.
How can you judge whether a policy is least-privilege?
Review the policy against the function’s real code paths and trigger configuration. A tighter design uses only necessary actions, limits resources to the required bucket or objects, restricts invocation to the intended S3 source and account, and avoids sharing a broad role across unrelated functions. A policy is not useful if it blocks required work, so validate normal and less-common paths after narrowing it.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




