In this part, we will create a Policy that grants the Lambda function permission to get, write, and delete objects in the S3 bucket.
Navigate to console of created in step 1 Lambda function.
Click Add permissions
Click Create policy
Click Choose a service and Enter S3, then select S3
Click Action, expand Read in Access level
Then, expand Write
In Resource, click Add ARN to specify resources.
Enter bucket name: book-image-shop
Click Add additional permissions
Repeat steps 4 and 5 and
Repeat steps 8 and 9 with bucket name is book-image-resize-shop
Click Next, Enter policy name, such as: LambdaResizeImageS3Policy
Back to adding policy for Lambda function screen, enter the name of the policy we just created.
We have finished granting the Lambda function read, write, and delete permissions from the S3 bucket. The next step is to test the Lambda function working when uploading an image.