We can create different versions of the launch template with configuration changes, here we gonna change the userdata script (web server homepage content)
1. Select the launch template > actions > Modify(Create new version) : It open the dashboard to edit
2.Updated the userdata : Go to advanced settings > Userdata then modify the content with the below script
#!/bin/bashsudo suyum update -yyum install httpd -ycd /var/www/htmlecho “Welcome to Amazon Linux 2023 – WebServer Launch Template v2” > index.htmlservice httpd startchkconfig httpd on |
Verify the summary and create launch template version
To check the creation, go to the EC2 > Instances > launch template : here you can the launch template with latest version 2
Creating the EC2 using Launch template |
1. Select Launch instances at Instances and select the Launch instance from the template
2. Verify and create the instance(Launch instance)
3. Launch instance is created
4. Verifying at the instance list
5. Verifying the web server installation, by copying public ip and running it on web browser
6. Successful, the version2 template is worked, we can see the mentioned information that what we changed in launch template while creating the version
7. Checking the version 1 : launching the instance from launch template verison 1
8. To check the launch template used and details , select the instance and go to tags at bottom session, here we can see the details
9. Verifying the Web server by copying the public ip from the instance created using the launch template version 1, it also working, we can see first userdata information showing here