AWS Certified Developer – Associate (DVA-C02) — Question 161

A developer has code that is stored in an Amazon S3 bucket. The code must be deployed as an AWS Lambda function across multiple accounts in the same AWS Region as the S3 bucket. An AWS CloudFormation template that runs for each account will deploy the Lambda function.

What is the MOST secure way to allow CloudFormation to access the Lambda code in the S3 bucket?

Answer options

Correct answer: A

Explanation

The correct answer is A, as it grants the necessary permissions while specifying the principal accounts, ensuring limited access to only authorized accounts. Option B is less secure because it uses a wildcard principal, allowing access to anyone. Options C and D incorrectly suggest granting permissions directly to the Lambda function instead of the CloudFormation service role, which does not address the specific requirements of the question.