When a Lambda function or an EC2 instance needs to read from
S3, the BEST way to give it permissions is:
A) Hard-code an IAM user's access key in the code.
B) Attach an IAM ROLE (instance profile / Lambda execution role) — the
credentials are short-lived and rotated automatically.
C) Run the function as the AWS root user.
D) Use a public bucket so no creds are needed.Sign in to save your code and track progress across devices.