AWS Lambda-backed Custom Resource in CloudFormation Template
This is a sample CloudFormation template that uses an AWS Lambda function as a custom resource. The Lambda retrieves the most recent HVM-based Amazon Linux or Windows 2012 R2 AMI ID based on the desired OS type assigned via input parameter. This was adapted from this example from the CloudFormation documentation.
Use the following steps to launch the template.
Note: You can use the OSType parameter to set the operating system. By default, it is set to Amazon Linux, but also supports Windows Server 2012 R2.