In AWS, a Launch Template is a resource that defines the configuration settings used to launch EC2 instances. It acts as a blueprint that specifies the instance configuration, such as instance type, Amazon Machine Image (AMI), security groups, key pairs, storage, and other parameters, making it easier to launch instances with predefined configurations.

Image

Screenshot 2025-02-23 at 5.21.21 PM.png

Security gruop

Screenshot 2025-02-23 at 5.20.50 PM.png

User data

User Data in AWS Launch Templates refers to a script or configuration file that you can provide when launching an EC2 instance. This script runs automatically during the instance's initialization process, allowing you to perform tasks like configuring the instance, installing software, or setting up services without needing to log in to the instance manually.

#!/bin/bash 
export PATH=$PATH:/home/ubuntu/.nvm/versions/node/v22.14.0/bin/
npm install -g pm2
cd /home/ubuntu/ASG
pm2 start --interpreter /home/ubuntu/.nvm/versions/node/v22.14.0/bin/bun bin.ts

Debugging - https://stackoverflow.com/questions/15904095/how-to-check-whether-my-user-data-passing-to-ec2-instance-is-working