AWS EC2 instance creation.
-
Factors involved:
- Instance type
- AMI
- Network (VPC)
- subnet (AZ)
- public ip (optional)
- Storage:
- Disk (EBS Volume)
- Permissions for ec2 (IAM Role)
- Cloud-init or UserData
- The Root EBS Volume (volume with os) will be from a different physical server to the physical server chosen to create a ec2 instance.
-
Cloud-init or UserData is a script or configuration which is execute only once during creation.
- Billing by state
lets create an ec2 instance with a user data to install apache server
-
Launch ec2
- select ami
- select instance type (free tier eligible t2.micro/t3.micro)
- select network
- az
- security group
- Expand Advanced Details
- Userdata
- Userdata
- UserData is executed only once during creation.
-
The disk is attached to EC2 instance
-
For this ec2 which we have created on-demand we are paying for
- ec2 instance (hourly billing)
- ebs volume
- public ip address (dynamic)
- In on-demand when we stop the instance
- ec2 instance billing stops
- public ip address billing stops
- ebs volume billing continues.
- Troubleshooting scenario:
- If my userdata is wrong aws will not alert, to check the status of execution login into ec2 and look for
/var/log/cloud-init.logand/var/log/cloud-init-output.log
- If my userdata is wrong aws will not alert, to check the status of execution login into ec2 and look for
Resizing the ec2 instances
- AWS allows to resize instances only is ec2 is in stopped state.
- in the below image the ec2 instance is in running state
- Resize (Vertical scaling)
