Preventing Cross-Environment Lambda Invocations via Resource Policies
Short answer
C Add a resource policy to the production Lambda function to allow only the production environment S3 bucket to invoke the function.
Question
After a recent production deployment, the development team observed that the development S3 buckets invoked the production environment Lambda functions. These invocations caused unwanted execution of development S3 files by using production Lambda functions. The development team must prevent these invocations. The team must follow security best practices.
Which solution will meet these requirements?
Key Takeaways
The exam tests your ability to apply least-privilege access controls using Lambda resource policies, often trapping candidates who over-engineer solutions with multi-account setups when a simpler policy fix suffices.
This question addresses how to prevent unintended cross-environment Lambda invocations caused by shared S3 triggers within a single AWS account. It establishes that applying resource-based policies is the direct and secure method to scope access.
Common mistake: Many candidates choose Option B because they prioritize 'best practices' for isolation (multi-account) over the specific technical requirement to stop the immediate trigger conflict, leading to unnecessary architectural changes.
Expert Analysis
Why the Answer Is Correct
Option C is the correct solution because it directly addresses the root cause: the production Lambda function lacks restrictions on which S3 buckets can invoke it. By attaching a resource-based policy to the production Lambda function that explicitly allows invocation only from the production S3 bucket's ARN, you enforce strict access control without changing the account structure. This aligns with AWS security best practices for scoping permissions.
Why the Other Options Are Wrong
Option A modifies the execution role, which controls what the Lambda function does after invocation, not who can trigger it. Options B and D suggest moving environments into separate accounts. While multi-account strategies are a valid long-term best practice for isolation, the question asks for a solution to prevent these specific invocations following best practices in the current context. Adding a resource policy is the standard, immediate remediation for this specific permission gap. Furthermore, Option D adds unnecessary complexity regarding execution roles for reading data, which doesn't solve the invocation trigger issue.
Community Comment Notes
Community consensus is split, with many users favoring Option B due to the phrase "security best practices," interpreting it as a mandate for account separation. However, as noted by user AgboolaKun, "the resource policy in the production environment can be used to control which S3 bucket invokes the function," making C the technically precise answer for the stated problem. User SD_CS also highlights that while separation is good, the resource policy "fulfill[s] requirement" directly. The key is recognizing that the question describes a permission misconfiguration solvable by IAM/Resource policies rather than an infrastructure design flaw requiring account migration.
Official Reference
https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html
This link opens the official vendor documentation in a new tab.
Exam Strategy
When a question specifies a technical failure (like unwanted invocations) and asks for a solution adhering to best practices, look for the most direct permission control mechanism first (e.g., Resource Policies). Do not jump to complex architectural changes like multi-account setups unless the question explicitly demands complete tenant isolation or mentions billing/account-level boundaries.
Frequently Asked Questions
Why isn't separating accounts required?
Does modifying the execution role help?
Community Votes
66% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 40 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 30 of 40
-
AgboolaKun 👍 31 Answered CB is a wrong answer because I do not understand the need to move the environments to separate AWS accounts. The resource policy in the production environment can be used to control which S3 bucket invokes the function. In my understanding, the answer choice C fulfills the security best practices requirement in the question.
-
csG13 👍 23 Answered BI choose B because it says that the team should follow the best security practices. AWS well-architected framework suggests separation. For reference see the link below: https://wa.aws.amazon.com/wat.question.SEC_1.en.html
-
MrPie 👍 15It's a best practice: Best Practices: Separate workloads using accounts: Establish common guardrails and isolation between environments (such as production, development, and test) and workloads through a multi-account strategy. Account-level separation is strongly recommended, as it provides a strong isolation boundary for security, billing, and access. https://wa.aws.amazon.com/wat.question.SEC_1.en.html
-
SD_CS 👍 4 Answered BI initially thought C, but after going through the below, I dont think there is any scope for doubt. stablish common guardrails and isolation between environments (such as production, development, and test) and workloads through a multi-account strategy. Account-level separation is strongly recommended, as it provides a strong isolation boundary for security, billing, and access https://docs.aws.amazon.com/en_us/wellarchitected/latest/framework/sec_securely_operate_multi_accounts.html
-
Rameez1 👍 4 Answered BMoving the Dev and Prod environments to separate Accounts will make them totally isolated with cross account Lambda invocations. Whereas in Option C though Prod Lambda won't trigger with Dev S3 bucket Event, Dev Lambda may still get mistakenly invoked by Prod S3 Bucket event and perform unwanted actions.
Show 25 more comments
-
wh1t4k3r 👍 3"The team must follow security best practices" Security best practices state that prod should be separated from non prod environments.
-
jipark 👍 3resource policy totally fulfill requirement
-
love777 👍 2C. Add a resource policy to the production Lambda function to allow only the production environment S3 bucket to invoke the function. Explanation: In this scenario, the goal is to prevent unwanted invocations of production Lambda functions by development S3 buckets. Adding a resource policy directly to the production Lambda function that restricts invocations to only the production S3 bucket ensures that the function is only invoked by the intended bucket. ChatGPT
-
KarBiswa 👍 2 Answered DI feel it is D as there is no doubt we need to separately create two accounts for DEV & PROD. After that there must lambda execution roles where we can the specific policies. Resource based policies more of a Cross Account access. https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html https://repost.aws/knowledge-center/lambda-execution-role-s3-bucket As the question demands the best practices scenario so option D fulfils that.
-
nbxyzd 👍 2 Answered BPls pay attention to keywords when you do aws quizzes. The best security practice: option B The lowest operational cost: option C. So B is definitely the answer.
-
Certified101 👍 2 Answered BB - following best practices
-
rodrigo35 👍 1 Answered CLa respuesta correcta es C. Agregue una directiva de recursos a la función Lambda de producción para permitir que solo el depósito del entorno de producción S3 invoque la función. ¿Por qué? Cuando Amazon S3 invoca una función Lambda, la autorización se controla mediante una resource-based policy en la función Lambda, no mediante el rol de ejecución de Lambda. B. Incorrecta. Separar cuentas es una buena práctica de aislamiento, pero no es suficiente por sí sola. Además, la opción habla de permitir que cualquier bucket de la misma cuenta invoque la función, cuando el requisito es permitir únicamente el bucket de producción.
-
SerialiDr 👍 1 Answered CThis approach involves configuring a resource-based policy (also known as a Lambda function policy) that explicitly defines which resources (in this case, S3 buckets) can invoke the Lambda function. By specifying only the production S3 bucket in the resource policy of the production Lambda function, you ensure that only events from the designated production S3 bucket can trigger the production Lambda function. This prevents development or other non-production buckets from inadvertently invoking production Lambda functions, thus maintaining environment integrity and security best practices.
-
sumanshu 👍 1 Answered CA) Eliminated - This approach focuses on the Lambda function's ability to read from S3, not on which S3 buckets can invoke it. B) Eliminated - Moving environments to separate AWS accounts might improve isolation but is not necessary to solve the stated problem C) Correct - The resource policy in Option C restricts Lambda function invocations to only the intended production S3 bucket. This is a direct implementation of AWS's least privilege security model
-
wmv__ 👍 1 Answered CAmazon S3 can invoke a Lambda function only if the Lambda function's resource-based policy allows it. In this case, development S3 buckets are incorrectly configured to invoke the production Lambda function. This implies that the resource policy on the production Lambda function is too permissive. To fix this, you should restrict the Lambda function’s resource policy so that only the production S3 bucket has permission to invoke it.
-
AmitRanchi 👍 1 Answered CBecause- B. Move the development and production environments into separate AWS accounts: While moving to separate accounts is a good practice for environment isolation, it's a more complex and potentially costly solution. Also, it isn't strictly necessary to achieve the goal of preventing unauthorized invocations, which can be accomplished via resource policies. It adds overhead without directly addressing the root cause.
-
Millie024 👍 1B seems to be the correct one https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_securely_operate_multi_accounts.html Establish common guardrails and isolation between environments (such as production, development, and test) and workloads through a multi-account strategy. Account-level separation is strongly recommended, as it provides a strong isolation boundary for security, billing, and access.
-
rodrigo35 👍 1La frase: "El equipo debe seguir las mejores prácticas de seguridad" es la que lleva a muchos a escoger B. Pero si AWS hubiera querido que la respuesta fuera B, normalmente la opción también habría restringido la invocación al bucket específico de producción. En cambio, B deja una superficie de acceso más amplia ("cualquier bucket de la misma cuenta"), lo cual contradice el principio de mínimo privilegio.
-
mooncake1 👍 1 Answered CSeparating account can be more secure and easy but maintenance will be more hard. It is developer's role and ability to distinguish and maintain between two environments, not just splitting them because it's easy. What AWS wants as a DVA Certificate Member is not a person who splits the accounts because its easy , but is able to use IAM properly.
-
Dimix3 👍 1 Answered COption C focuses on securing the production Lambda function by adding a resource policy to restrict invocations. This policy would specify that only the production S3 bucket can trigger the production Lambda function. This prevents accidental invocations from development S3 buckets.
-
Anandesh 👍 1 Answered BEstablish common guardrails and isolation between environments (such as production, development, and test) and workloads through a multi-account strategy. Account-level separation is strongly recommended, as it provides a strong isolation boundary for security, billing, and access
-
rkotit 👍 1 Answered CWhen securing AWS Lambda functions, you must ensure that only authorized resources (like an S3 bucket) can trigger or invoke the function. In this scenario, the simplest and most effective solution is to use resource-based policies on the Lambda function to restrict access.
-
sumanshu 👍 1B) can be correct While this does restrict invocation to the production S3 bucket, keeping both environments in the same account is not a best security practice. A single-account setup increases the risk of misconfigurations, accidental access, and security breaches.
-
stilloneway 👍 1 Answered BSee the question, in terms of "Security best practices", Answer is B. It could be C for 2nd option if separate AWS account is not possible.
-
nbxyzd 👍 1Read carefully. The questions asks for 'the best' not the 'the simplest' security practice.
-
Aws_aspr 👍 1Asked 18 July 24 WIthout security best practices word. So C is correct answer for this.
-
Saurabh04 👍 1Option D is correct. This approach ensures isolation while maintaining manageability
-
maurice2005 👍 1There is nowhere mentioned in the question that workload is the problem!
-
Nagasoracle 👍 1 Answered AAnswer : A As it mentions to follow best security practice
-
queekao 👍 1 Answered COption C is the simplest way to achieve this requirement.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →