What is the recommended method for including Lambda resources within a CloudFormation stack deployment?
💡 Model Answer
The standard way to include Lambda functions in a CloudFormation stack is to declare an AWS::Lambda::Function resource in the template. You specify the function name, runtime, handler, code location (S3 bucket or inline code), and any required IAM role. CloudFormation then provisions the Lambda function along with any other resources in the same stack, ensuring that all dependencies are created in the correct order. Using IaC gives you version control, repeatable deployments, and the ability to roll back if something fails. You can also attach an AWS::Lambda::Permission resource to allow other services to invoke the function. Additionally, CloudFormation supports custom resources for actions that are not natively supported. When updating the function code, you can use the AWS::Lambda::Version resource to create immutable versions and set up aliases for routing traffic. CloudFormation also supports stack policies to protect critical resources during updates, preventing accidental deletions. By using nested stacks, you can modularize your infrastructure, reusing common Lambda patterns across multiple environments.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500