Wednesday, July 28, 2021
User Data in an instance allows you run commands while your instance boots up. In the previous posts we just plain vanilla instances so far. But in this post we are going to install the Apache Httpd service when we create our instance using User Data.
Here are the steps to create an instance with User Data:
In this blog we are going to start our journey into AWS infrastructure with the creation of an EC2 instance which is probably the most common task you'll ever do. Here are the steps to create an EC2 instance on AWS:
1. Log into AWS and on the "Find Services" search box type EC2 and press enter
2. You will be taken to EC2 screen, then click on "Instances"
2. Click on "Launch Instance"
3. On "Step 1: Choose an Amazon Machine Image (AMI)" screen select "Amazon Linux 2 AMI (HVM), SSD Volume Type"
4. On the "2. Choose Instance Type" screen select the one that says "Free tier eligible"
5. Then select "Next: Configuration Instance Details" at the bottom of the screen
6. On the "3. Configure Instance" select the subnets that are closest to you
7. Scroll down to the bottom of the page expand "Advance Details", and find the field that says "User Data" and type in the following commands into the field to first update the OS then install, start and enable the httpd service
#cloud-boothook
#!/bin/bash
#Use this for your user data (script without newlines)
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo "Hello world from $(hostname -f)" > /var/www/html/index.html
We just created an index.html file to write out the hostname for testing later on
8. Then select "Next: Add Storage" at the bottom of the screen
9. Accept the default and press "Next: Add Tags"
10. Select "Add Tag", then select "Next: Configure Security Group"
11. On this screen you are going to set the configuration for SSH and HTTP traffic, select "Create new security group" then give it a name and description. There will be and "SSH" rule already assigned accept it, now we are going to add the HTTP rule by clicking on the "Add Rule" button. Select "HTTP" from the dropdown list. In the IP range field type 0.0.0.0/0
11. Select "Review and Launch" at the bottom of the screen.
12. Make sure the t2.micro image is selected if you want to stay in the free tier, select "Edit instance type" to select it, if it's not. Then click "Launch"
13. On the "Launch Screen" click on the "Download Key Pair" to download the private key file(.pem). Make sure you remember where you download this file because you will need it to connect the instance later on. Give your key pair a name and select "Launch Instances"
14. On the "Launch Status" screen click on the instance link to see the status of instance deployment, it will take a couple of minutes to complete the deployment but eventually you will see the the "Instance State" is "running" and the "Status Checks" is good
You've just deployed an EC2 instance in the cloud. Now open a new tab on your browser and type in the http:// Public DNS or Public IP and you will see the hostname because the User Data has been ran
You can also add User Data to an instance that is already created by selecting Actions: Instance Settings: View/Change User Data
Finally you could access your User-Data with this endpoint
http://169.254.169.254/latest/user-data
Subscribe to:
Post Comments (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu
Nice Article Keep Work Doing.
ReplyDeleteNice Article Thank You For Sharing. How To Add Apps In Google Drive In Hindi?
We have read your blog. It was really informative and we have collected much knowledge that has assisted me a lot. People can also visit our website.
ReplyDeleteLove back Solution Specialist
Vashikaran specialist
Love Vashikaran Specialist
Vashikaran Specialist in India Vashikaran Specialist in Bangalore Vashikaran Specialist in Mumbai Love Vashikaran Specialist in MumbaiBlack magic specialist astrologer
Looking to spread some holiday cheer with these corporate christmas party entertainment ideas Consider incorporating interactive elements like a holiday-themed trivia game, where employees can showcase their festive knowledge. Hire a magician to dazzle guests with enchanting tricks and illusions, or set up a photo booth with fun props for memorable snapshots. You might also arrange a DIY ornament station, where teams can craft personalized decorations. These engaging activities not only foster team bonding but also ensure everyone leaves the party with a smile, making your corporate event truly unforgettable.
ReplyDelete