Aws Ec2
Aws Ec2
Aws Ec2
• On-Demand Instances
• Reserved Instances
• Spot Instances
On-Demand Instances:
The price per hour for each instance type published on the AWS website
represents the price for On-Demand Instances.
• We can specify the price they are willing to pay for a certain instance type.
• When the bid price is above the current Spot price, we’ll get the requested
instance.
Naresh i technologies Amazon Web Services Avinash Reddy T
• These instances will operate like all other Amazon EC2 instances, and the
customer will only pay the Spot price for the hours that instance(s) run.
The instances will run until:
Select the Launch instance option and it will launch an instance launch
wizard.
Naresh i technologies Amazon Web Services Avinash Reddy T
I want to launch an Amazon Linux AMI, so selecting Amazon Linux AMI from the
Quick Start menu.
Shutdown behavior: This option allows us to select whether the instance should
stop or be terminated when issued a shutdown request. In this case, we have
opted for the instance to stop when it is issued a shutdown command.
Enable termination protection: Select this option in case you wish to protect
your instance against accidental deletions. It adds additional step for instance
termination. If, we enable this option, we need to manually Disable to terminate
the instance.
Monitoring: By default, AWS will monitor few basic parameters about your
instance for free, but if you wish to have an in-depth insight into your instance’s
performance, then select the Enable CloudWatch detailed monitoring option.
But you’ll get charged for detailed monitoring.
Tenancy: We can choose to run our instances on physical servers fully dedicated
for your use. The use of host tenancy will request to launch instances onto
dedicated hosts.
Bootstrapping We can configure instances and install applications
programmatically when an instance is launched. The process of providing code
to be run on an instance at launch is called bootstrapping.
On Linux instances this can be shell script, and on Windows instances this can
be a batch style script or a PowerShell script.
• Try to keep the volume size under 30 GB, It’ll comes under free tier
eligibility.
• We can create volumes and attach to instance even after instance launch
also.
Naresh i technologies Amazon Web Services Avinash Reddy T
• You need to open SSH to Connect Linux machines, RDP for Windows
machines. HTTP and HTTPS if webservers.
• We can give 0.0.0.0/0 to connect this instance from any network and
subnet.
• We can select custom option and give the particular Network’s public IP,
then the service will be available for that particular network only.
Some Important points about Security Groups:
• You can create up to 500 security groups for each Amazon VPC.
• You can add up to 50 inbound and 50 outbound rules to each security
group. If you need to apply more than 100 rules to an instance, you can
associate up to five security groups with each network interface.
Naresh i technologies Amazon Web Services Avinash Reddy T
• You can specify allow rules, but not deny rules. This is an important
difference between security groups and ACLs.
• By default, no inbound traffic is allowed until you add inbound rules to
the security group.
• By default, new security groups have an outbound rule that allows all
outbound traffic.
• Security groups are stateful. This means that responses to allowed
inbound traffic are allowed to flow outbound regardless of outbound rules
and vice versa.
• You can change the security groups with which an instance is associated
after launch, and the changes will take effect immediately
Step 7: Review Instance Launch
Here in step 3, we will get review screen. We will get complete summary of our
instance’s configuration details, including the AMI details, instance type
selected, instance details, and so on. If all the details are correct, then simply go
and click on the Launch option.
Then we have to associate a key pair to our instance.
A key pair is basically a combination of a public and a private key, which is used
to encrypt and decrypt your instance’s login info. AWS generates the key pair for
you which you need to download and save locally to your computer.
Naresh i technologies Amazon Web Services Avinash Reddy T
Once a key pair is created and associated with an instance, we need to use that
key pair itself to access the instance. We will not be able to download this key
pair again so, save it in a secure location.
Select the Create a new key pair option from the dropdown list and provide a
suitable name for your key pair as well. Click on the Download Key Pair option
to download the .PEM file. Once completed, select the Launch Instance option.
Naresh i technologies Amazon Web Services Avinash Reddy T
• The dashboard provides all of the information about our instance. We can
view instance’s ID, instance type, IP information, AZ, Security Group, and
a whole lot more info.
• We can also obtain instance’s health information using the Status Checks
tab and the Monitoring tab.
• We can perform power operations on your instance such as start, stop,
reboot, and terminate using the Actions tab located in the preceding
instance table.
Connecting to Instance:
Once the instance is launched we have multiple options to connect to the
instance. Mostly we can use PuTTY to connect Linux machines and Remote
Desktop Feature for Windows Machine.
As we launched Linux machine, here we are going to see PuTTY option now.
PuTTY is basically an SSH and telnet client that can be used to connect to remote
Linux instances. But before you get working on Putty, we need a tool called
PuttyGen to convert the PEM file to PPK (Putty Private Key).
We can download the Putty.exe and PuttyGen.exe from the below URL:
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Naresh i technologies Amazon Web Services Avinash Reddy T
1. Download and install the latest copy of Putty and PuttyGen on local
computer.
2. Launch PuttyGen and select the Load button and browse the downloaded
Pem file (Which is created at the time of Instance launch).
7. In Putty, under Category pane, expand the SSH option and then select
Auth, then browse and upload the recently saved PPK file in the Private
key file for authentication field. Once uploaded, click on Open to
establish a connection to instance.
8. Give yes for on the Putty Security Alert.
Naresh i technologies Amazon Web Services Avinash Reddy T
9. In the Putty terminal window, provide the user name for your Amazon
Linux instance (ec2-user) and hit the Enter key. Now we have connected
to our first instance and it is ready for use
10 . Each Linux instance type launches with a default Linux system user
account. For Amazon Linux, the user name is ec2-user. For RHEL, the
user name is ec2-user or root. For Ubuntu, the user name is ubuntu or
root. For Centos, the user name is centos. For Fedora, the user name is
ec2-user. For SUSE, the user name is ec2-user or root. Otherwise, if ec2-
user and root don't work, check with your AMI provider.
Naresh i technologies Amazon Web Services Avinash Reddy T
For RHEL-based AMIs (Redhat), the user name is either root or the ec2-user,
and for Ubuntu-based AMIs, the user name is generally Ubuntu itself.
11 To connect to Windows Instance we have to use Remote Desktop
Connection application.
12 Open Run and enter mstsc and press enter
13 Note the public DNS/IP of the windows instance and enter it computer
field and click on Connect.
Naresh i technologies Amazon Web Services Avinash Reddy T
14 Now, It will ask you to enter the username and password to login to the
instance.
15 To get the Username and password to login to the instance we have get it
from EC2 console.
Naresh i technologies Amazon Web Services Avinash Reddy T
16 Select the instance which you want to get the UN & PWD. Go to Actions
and select the “Get Windows Password”, then browse the PEM file and
select “Decrypt Password” button.
Naresh i technologies Amazon Web Services Avinash Reddy T
17 Then you’ll get the UN and Password, you can enter this UN & Pwd and
click on connect, You’ll asked for Certificate error prompt, simply click on
Yes to connect to this machine.
Naresh i technologies Amazon Web Services Avinash Reddy T
Security groups
Security groups allow you to control traffic based on port, protocol, and
source/destination.
You can use Security Groups to restrict and filter out both the inbound and
outbound traffic of an instance using a set of firewall rules. Each rule can allow
traffic based on a particular protocol—TCP or UDP, based on a particular
port—such as 22 for SSH, or even based on individual source and destination
IP addresses. This provides lot of control and flexibility in terms of designing a
secure environment for instances to run from.
• Security groups are associated with instances when they are launched.
Every instance must have at least one security group but can have more.
• A security group is default deny; that is, it does not allow any traffic
that is not explicitly allowed by a security group rule.
• A security group is a stateful firewall, If you open some port in inbound,
it’ll automatically allowed for outbound also.
Naresh i technologies Amazon Web Services Avinash Reddy T
You can select the Protocol Type inn Type field, automatically it’ll show the
protocol type and Port Range, and then we have to select the source.
Source field where you can basically specify any of these three options:
Anywhere: Using this option as the source, particular application port will be
accessible from any and all networks out there (0.0.0.0/0). This is not a
recommended configuration by AWS.
My IP: AWS will autofill the IP address of your local computer/Network here. If
you select My IP option then the service works only in that particular network
only.
Custom IP: This is the most preferable option, the Custom IP option allows you
to specify your own custom source IP address or IP range as per our
requirements. Ex: allow the particular application to access only via traffic
coming from the network 202.153.31.0/24 CIDR.
Naresh i technologies Amazon Web Services Avinash Reddy T
• An io1 volume can range in size from 4 GiB to 16 TiB and you can provision
100 up to 20,000 IOPS per volume.
Create a Volume:
From the Volume Management dashboard, select the Create Volume option.
Naresh i technologies Amazon Web Services Avinash Reddy T
Type: From the Type drop-down list, select either General Purpose (SSD),
Provisioned IOPS (SSD), or Magnetic as per the requirements.
Size (GiB): Provide the size of your volume in GB.
IOPS: This field will only be editable if you have selected Provisioned IOPS
(SSD) as the volume’s type. Enter the max IOPS value as per your
requirements.
Availability Zone: Select the appropriate availability zone in which you wish to
create the volume.
Snapshot ID: This is an optional field. We can choose to populate your EBS
volume based on a third party’s snapshot ID.
Encryption: We can choose whether or not to encrypt EBS Volume. Select
Encrypt this volume checkbox if you wish to do so.
Master Key: On selecting the Encryption option, AWS will automatically create
a default key pair for the AWS’s KMS.
Naresh i technologies Amazon Web Services Avinash Reddy T
Once configuration settings are filled in, select Create to complete the volume’s
creation process. The new volume will take a few minutes to be available for
use. Once the volume is created, we can now attach this volume to running
instance.
Attaching EBS Volumes: Once the EBS volume is created, make sure it is in
the available state before you go ahead and attach it to an instance. You can
attach multiple volumes to a single instance at a time.
When you select instance field, automatically you’ll get thee running instances
list from that particular availability zone. Select the Instance you want to
attach this volume. Then click on Attach. Now the Volume state will change to
in-use from Available.
Naresh i technologies Amazon Web Services Avinash Reddy T
We have to mount this volume from operating system level. For windows, you
have to perform it though Disk Management option.
In Linux:
1. Elevate your privileges to root.
2. Type df –h command to check the current disk partitioning of instance.
3. Give fdisk –l command to verify the newly added disk.
4. We have to choose the file system type. Here am using ext4 file system.
Then run the following command.
mkdir /newvolume
mount /dev/xvdf /newvolume
Naresh i technologies Amazon Web Services Avinash Reddy T
4. The newly created 2GB volume is attached to the Windows instance and
by default the status of this drive will set to offline, Select the Disk 1,
then choose Online option to make the volume online.
Naresh i technologies Amazon Web Services Avinash Reddy T
5. Here we have to initialize the Disk, Give right click on Disk then select
the initialize disk option and click on OK
6. Now we have to create a volume, Give right click on dive select the “New
Simple Volume” option, It will open up a Volume creation wizard, follow
the wizard as below images
Naresh i technologies Amazon Web Services Avinash Reddy T
Naresh i technologies Amazon Web Services Avinash Reddy T
Naresh i technologies Amazon Web Services Avinash Reddy T
7. Now we can see the newly created volume along with other volumes. You
can use the Disk Management console to Shrink, extend or to delete the
volumes.
RAM disk ID, Kernel ID: We can select and provide your AMI with its own
RAM disk ID (ARI) and Kernel ID (AKI); however, in this case I have opted to
keep the default ones.
Block Device Mappings: We can use this dialog to either expand root volume’s
size or add additional volumes to it. We can change the Volume Type from
General Purpose (SSD) to Provisioned IOPS (SSD) or Magnetic as per our AMI’s
requirements.
Click on Create to complete the AMI creation process. The new AMI will take a
few minutes to spin up.
We can select the AMI and choose Launch option to launch a new instance. We
will get the instance launch wizard.
• AMI are regional, if required we can copy AMI to another region with
Copy option.
• We can share the AMI to any other AWS account users or we can make it
public.
• Every AMI will associate with a Snapshot.
• AMI are registered with the AWS accounts, if you no longer required any
AMI, you can select Deregister option under Actions.
• We cannot delete the Snapshot if it is associated with an AMI.
The Elastic Load Balancing service allows you to distribute traffic across a group
of Amazon EC2 instances enabling you to achieve high availability in your
applications.
Elastic Load Balancing supports routing and load balancing of Hypertext
Transfer Protocol (HTTP), Hypertext Transfer Protocol Secure (HTTPS),
Transmission Control Protocol (TCP), and Secure Sockets Layer (SSL) traffic to
Amazon EC2 instances.
Elastic Load Balancing supports health checks for Amazon EC2 instances to
ensure traffic is not routed to unhealthy or failing instances.
We will not get any public IP address for ELBs, We will get a DNS record for every
LB.
Advantages of ELB
• Elastic Load Balancing is a managed service, it scales in and out
automatically to meet the demands of increased application traffic and is
highly available within a region itself as a service.
• ELB helps you achieve high availability for your applications by
distributing traffic across healthy instances in multiple Availability Zones.
• ELB seamlessly integrates with the Auto Scaling service to automatically
scale the Amazon EC2 instances behind the load balancer.
• ELB is secure, working with Amazon Virtual Private Cloud (Amazon VPC)
to route traffic internally between application tiers, allowing you to expose
only Internet-facing public IP addresses.
• ELB also supports integrated certificate management and SSL
termination.
Ping protocol: This field indicates which protocol the ELB should use to connect
to EC2 instances. We can use the TCP, HTTP, HTTPS, or the SSL options.
Ping port: This field is used to indicate the port which the ELB should use to
connect to the instance.
Ping path: This value is used for the HTTP and HTTPS protocols. Can also use
a /index.html here.
Response time: The Response Time is the time the ELB has to wait in order to
receive a response. The default value is 5 seconds with a maximum value up to
60 seconds.
Health Check Interval: This field indicates the amount of time (in seconds) the
ELB waits between health checks of an individual EC2 instance. The default
value is 30. Maximum value is 300 seconds.
Unhealthy Threshold: This field indicates the number of consecutive failed
health checks an ELB must wait before declaring an instance unhealthy. The
default value is 2 with a maximum threshold value of 10.
Healthy Threshold: This field indicates the number of consecutive successful
health checks an ELB must wait before declaring an instance healthy. The
default value is 2 with a maximum threshold value of 10.
Naresh i technologies Amazon Web Services Avinash Reddy T
7. Step 5 – Add EC2 instances: We can select any running instance from
Subnets to be added and registered with the ELB. Select the EC2 instances
you want to launch under this ELS then Click on Next: Add Tags to proceed
with the wizard.
8. In next step, Add any of the tags required and Review the option and click
on Create option.
9. I have a installed httpd package and created an Index.html file under
/var/www/html path in ec2 instance then started the httpd service and
am able to get the webpage using the Instance’s public IP.
10. And Here is the details for created ELB, As we know we’ll get a DNS
name for our created ELB, We can access the same webpage by using the
ELB’s DNS name also.
Naresh i technologies Amazon Web Services Avinash Reddy T
11. We are able to get the same page by using the DNS name of ELB.
This means our ELB configured successfully.
Naresh i technologies Amazon Web Services Avinash Reddy T
Auto Scaling
Auto Scaling is a service that allows us to scale our Amazon EC2 capacity
automatically by scaling out and scaling in according to criteria that we define.
With Auto Scaling, we can ensure that the number of running Amazon EC2
instances increases during demand spikes or peak demand periods to maintain
application performance and decreases automatically during demand lulls or
troughs to minimize costs.
Launch Configuration
A launch configuration is the template that Auto Scaling uses to create new
instances, and it is composed of the configuration name, Amazon Machine Image
(AMI), Amazon EC2 instance type, security group, and instance key pair. Each
Auto Scaling group can have only one launch configuration at a time.
Auto Scaling Group
An Auto Scaling group is a collection of Amazon EC2 instances managed by the
Auto Scaling service. Each Auto Scaling group contains configuration options
that control when Auto Scaling should launch new instances and terminate
existing instances. An Auto Scaling group must contain a name and a minimum
and maximum number of instances that can be in the group. You can optionally
specify desired capacity, which is the number of instances that the group must
have at all times. If you don’t specify a desired capacity, the default desired
capacity is the minimum number of instances that you specify.
Scaling plans
With your Launch Configuration created, the final step left is to create one or
more scaling plans. Scaling Plans describe how the Auto Scaling Group should
actually scale.
• Manual scaling: here is specify a new desired number of instances value
or change the minimum or maximum number of instances in an Auto
Scaling Group and the rest is taken care of by the Auto Scaling service
itself
• Scheduled scaling: We can scale resources based on a particular time and
date
• Dynamic scaling: Dynamic scaling, or scaling on demand is used when the
predictability of your application’s performance is unknown.
Auto scaling group creation involves with two steps. First one is Creating a
Launch Configuration and second is Creating Auto Scaling group.
Naresh i technologies Amazon Web Services Avinash Reddy T
Each instance in this Auto Scaling Group will be provided with a public IP
address.
5. We can expand Advanced details option to configure.
Load Balancing: These are optional settings that you can configure to work with
your Auto Scaling Group. Since we have already created and configured our ELB,
we will be using that itself to balance out incoming traffic for our instances.
Select the Receive traffic from Elastic Load Balancer option.
Health Check Type: You can use either your EC2 instances or even your ELB
as a health check mechanism to make sure that your instances are in a healthy
state and performing optimally. By default, Auto Scaling will check your EC2
instances periodically for their health status. If an unhealthy instance is found,
Auto Scaling will immediately replace that with a healthy one.
Health Check Grace Period: Enter the health check’s grace period in seconds.
By default, this value is set to 300 seconds.
Naresh i technologies Amazon Web Services Avinash Reddy T
Creating the alarm is a very simple process; for example, we want our Auto
Scaling Group to be monitored based on the CPU Utilization metric for an interval
of 5 minutes. If the average CPU Utilization is greater than or equal to 90 percent
for at least one consecutive period, then send a notification mail to the specified
SNS Topic. click on Create Alarm.
Take the action: Now we can define the policy what action it has to take if the
particular threshold is breached. Select Add from the dropdown list and provide
a suitable number of instances that you wish to add when a certain condition
matches.
Instances need: The final field is the Cooldown period. By default, this value is
set to 300 seconds and can be changed as per your requirements. A Cooldown
period is like a grace period that we assign to the Auto Scaling Group to ensure
Naresh i technologies Amazon Web Services Avinash Reddy T
that we don’t launch or terminate any more resources before the effects of
previous scaling activities are completed.
8. By the same way we can configure policies for Decrease Group Size also
9. Select the Next: Configure Notifications to proceed with the next steps
10. You can select Add Notification button and select an existing SNS
topic or create a new.
11. Select the review option and Click on Create Auto Scaling option to
finish the process.
Naresh i technologies Amazon Web Services Avinash Reddy T
USER DATA:
When you launch an instance in Amazon EC2, you have the option of passing
user data to the instance that can be used to perform common automated
configuration tasks and even run scripts after the instance starts.
You can pass two types of user data to Amazon EC2: shell scripts and cloud-init
directives. You can also pass this data into the launch wizard as plain text, as a
file (this is useful for launching instances using the command line tools), or as
base64-encoded text.
Here is a simple User Data script to use with Linux EC2 instances to make as
a simple webserver with a simple index.html page.
#!/bin/bash
yum update -y
yum install httpd -y
echo "Hi This is a Bootstrap script generated webpage" >
/var/www/html/index.html
service httpd start
chkconfig httpd on
Naresh i technologies Amazon Web Services Avinash Reddy T
“yum update” for updating the Operating system with latest security patches.
“Yum install httpd” for installing Apache to make this instance as a webserver
By Using echo command generating a string and copying the generated string to
a file named “index.html” and saving the file under “/var/www/html” directory.
“Service httpd start” to start the apache service
“Chkconfig httpd on” starting and turning the service on / startup service.
2. Then launching the instance and entering the public IP in the web browser
without connecting to my instance. (Make sure port 80 open in the
Security groups)
For Windows:
For EC2Config or EC2Launch to execute user data scripts, you must enclose
the lines of the specified script within one of the following special tags:
<script> </script>
Example: <script>dir > c:\test.log</script>
1. Here we have run very simple script get directory information to a log file.
New doc is created with all the information of the given directory.
2.
Naresh i technologies Amazon Web Services Avinash Reddy T
• Here is the url to get all the commands for each and every AWS service:
http://docs.aws.amazon.com/cli/latest/reference/
4. But we cannot configure CLI tools using IAM Management console access
users, we need to have Programmatic Access IAM user.
5. When we create a Programmatic Access IAM user we will get Access key
ID and Secret Access Key. Please create a user and allocate appropriate
permissions.
6. To configure IAM user in local windows machine, we have to “AWS
configure” command.
7. Enter the AWS Access Key ID and then enter the Secret Access key, choose
the default region and default output format.
8. We have successfully configured the CLI tools and now try to access any
of the AWS resource from the CLI configured device. Here am trying to list
my S3 buckets for that am using aws s3 ls command.
Naresh i technologies Amazon Web Services Avinash Reddy T
9. We are able to get the details that means we are connecting to AWS
account resources by using the Programmatic access IAM user credentials.
10. But, the IAM user credentials will store in a directory called .aws ,
In windows the path is
C:\Users\WindowsUserName\.aws , if you open credentials file, we will
get the Configured IAM user’s Aceess Key ID and Secret Access Key.
11. In Linux, The .aws directory will store under / (root) and It is a
hidden directory, we can give ls –a command to get it, and inside the .aws
directory we will have config and credentials files.
Naresh i technologies Amazon Web Services Avinash Reddy T
12. In the above image, I’ve logged into the linux instance and switched
to root, looked for .aws directory, but it is not existed. Then Configured the
IAM user with Access Key IA and Secret Access Key and accessed the AWS
resources and we get the required resource information.
13. After installing CLI IAM user, we got .aws directory under / (give ls
–a to verify), inside that .aws directory we have config and credentials files,
Credential file will contains the Access Key id and secret access key.
14. So this is not a secure method, anybody can view these credentials
and configure CLI tools on their own machines and they may access, So
amazon will recommend to use the ROLES instead of storing the
credentials in local machines.
IAM ROLES:
Roles are used to allow AWS services to perform actions on your behalf. Roles
are used to grant specific privileges to specific actors.
• Roles are more secure than storing your access key and secret access key
on individual EC2 instances.
• Roles are easier to manage
• We can attach or Remove role to a running instance now. Previously this
option is not available.
• Roles are universal, you can use them in any region.
3. We have four option in the roles, We are going to create this role under
“AWS Services”, and select the EC2.
4. After selecting EC2, we have to select the appropriate Use Case. We would
like to call some AWS services on our behalf to the EC2 instance. Select
EC2 and click on Next: Permissions button.
Naresh i technologies Amazon Web Services Avinash Reddy T
5. In this step, we have to select the policy, you can generate a new policy
based on your requirement or choose existing policy.
8. Now launch an EC2 instance and try to access/call any AWS service to
verify the role.
9. Logged into EC2 instance and elevated privileges to root and trying to find
the .aws directory under / , but we cannot find, That means we don’t have
any credentials on instance.
Naresh i technologies Amazon Web Services Avinash Reddy T
10. Try to access any AWS service, here am trying to list the S3 buckets
by AWS s3 ls command.
11. We are able to access the resources and nowhere storing the Access
key ID and Secret Access key.
2. Select IAM role filed, automatically it will dropdown the available roles
along with No Role option, Select the required option and click on Apply.
It will take effect immediately.
Naresh i technologies Amazon Web Services Avinash Reddy T
Instance Metadata:
Instance metadata is data about your instance that you can use to configure or
manage the running instance. This is unique in that it is a mechanism to obtain
AWS properties of the instance from within the OS. By using below URL we can
query the local instance metadata.
• Curl http://169.254.169.254/latest/meta-data/
• When you enter this URL, it’ll return with all the available information to
get. We can give the required option after meta-data/ you’ll get the
information.
Steps to get the instance Metadata:
1. I’ve logged into my EC2 instance
2. Enter the metadata url
3. It is returned with all the available option, now whatever the information
you want to get, give it along with the URL.
Ex: if you want to know hostname, give as Curl
http://169.254.169.254/latest/meta-data/hostname
Naresh i technologies Amazon Web Services Avinash Reddy T
AWS CLOUDWATCH
Amazon CloudWatch is a service that you can use to monitor your AWS
resources and your applications in real time. With Amazon CloudWatch, you can
collect and track metrics, create alarms that send notifications, and make
changes to the resources being monitored based on rules you define.
• You can specify parameters for a metric over a time period and configure
alarms and automated actions when a threshold is reached.
• Amazon CloudWatch offers either basic or detailed monitoring for
supported AWS products.
• Basic monitoring sends data points to Amazon CloudWatch every five
minutes for a limited number of preselected metrics at no charge.
• Detailed monitoring sends data points to Amazon CloudWatch every
minute and allows data aggregation for an additional charge. If you want
to use detailed monitoring, you must enable it—basic is the default.
• AWS provides a rich set of metrics included with each service, but you can
also define custom metrics to monitor resources and events.
• Amazon CloudWatch Logs can be used to monitor, store, and access log
files from Amazon EC2 instances.
• Amazon CloudWatch Logs can also be used to store your logs in Amazon
S3 or Amazon Glacier.
• Each AWS account is limited to 5,000 alarms per AWS account, and
metrics data is retained for two weeks by default.
You can configure the alerts on your AWS usage by using the Cloudwatchh
alarms. Here is the steps to create an alarm on estimated charges.
1. Login with root account credentials.
2. Select My Account option and navigate to “Preferences”
3. Go to Select Receive Billing Alerts checkbox and select “Manage Billing
Alerts” option. (Cloudwatch alarms will create in North Virginia region).
5. In this windows, enter the USD value, when you want to receive the
notifications and enter your email id which you want to get the
notifications, Click on “Create Alarm” When your monthly usage reaches
to 5$ you’ll get notified by the cloudwatch service through the mentioned
email.
6. AWS does not allow the billing alarm’s period to be set less than 6 hours.
Here is how exactly billing alarm looks like.
Naresh i technologies Amazon Web Services Avinash Reddy T
Whenever this alarm: This option will allow you to determine when the alarm
will actually perform an action. There are three states of an alarm out of which
you can select any one at a single time:
State is ALARM: Triggered when the metric data breaches the threshold
value set by you
State is OK: Triggered when the metric data is well within the supplied
threshold value
State is INSUFFICIENT: Triggered when the alarm generally doesn’t have
enough data with itself to accurately determine the alarm’s state.
The x axis displays the CPU utilization in percent whereas the y axis display the
time as per the current period’s settings. We can view the individual data points
and their associated values by simply hovering over them on the graph.
Alternatively, you can also switch between the Statistics, Time Range, and Period
as per our requirements.
1. Once you have viewed your instance’s performances, you can create a
simple alarm by selecting the Create Alarm option provided in the
Monitoring tab.
2. Click on Create Alarm option as shown below image.
3. Now you’ll get a windows with all the available options to create an alarm.
Naresh i technologies Amazon Web Services Avinash Reddy T
3. So, I switched to N. Virginia to perform the lab and selected EFS and select
Create file system option.
4. Select your VPC and Subnets, if you don’t want to make this file system
available to any specific subnet, Just untick that here. Then select Next.
Naresh i technologies Amazon Web Services Avinash Reddy T
5. If we want to add tags, we can add here and we need to select the
Performance Mode. We have to select this based on EC2 instance count.
6. If we want to encrypt the data storing under EFS, we can enable the option
on same page, then click on NEXT.
Naresh i technologies Amazon Web Services Avinash Reddy T
7. Review all the options and select Create File System option, file system will
be created now and available for usage.
12. In above image, I’ve elevated my privileges to root and tried to install
the required nfs-utils, but It’ll installed by default in Amazon Linux
Instances.
• Created a directory named efs with “sudo mkdir efs” command.
• And executed the mounting command to the created directory, now
whatever the files I created under “efs” is going to available for all
EC2 instances.
• If you want to test this, perform the same steps in another EC2
instance and test it.
13. If you want to delete the EFS, Select the EFS and go to “Actions”
and “Delete File System”.
14. Enter the file system’s ID in the box and select the “Delete File
System” button, File system will delete now.
Naresh i technologies Amazon Web Services Avinash Reddy T
LIGHTSAIL
With Amazon Lightsail with a couple of clicks we can choose a configuration from
a menu and launch a virtual machine preconfigured with SSD-based storage,
DNS management, and a static IP address.
We can launch it on Amazon Linux AMI or Ubuntu operating system, developer
stack (LAMP, LEMP, MEAN, or Node.js), or application (Drupal, Joomla,
Redmine, GitLab, and many others), with flat-rate pricing plans that start at $5
per month including a generous allowance for data transfer.
Steps to launch Lightsail Instance
Naresh i technologies Amazon Web Services Avinash Reddy T
3. Select the Region and Zone, then select the Platform, and a blueprint what
instance what application we required. Now am going to launch Wordpress
website.
Naresh i technologies Amazon Web Services Avinash Reddy T
4. And give a name for your instance and select Create option.
Naresh i technologies Amazon Web Services Avinash Reddy T
5. When the instance is ready select the connect option and you’ll get a
console.
6. We’ll get a public IP address by using that Public IP, we can access the WP
website.
7. We will get a default template, if you want to customize that we have to
login to the Admin panel. Here I’ve entered public IP the browser. In bottom
corner, We will get Manage button, select that to login.
Naresh i technologies Amazon Web Services Avinash Reddy T
11. After authenticating, we’ll login to the WP website and we can start
customizing the website and select the Publish then the changes will
update immediately.
Naresh i technologies Amazon Web Services Avinash Reddy T
12. If you want to manage your instance you can select the Manage
option and you’ll get the options to view the Metrics, Networking,
Snapshots for backup, History and Delete options.
Elastic Beanstalk
With Elastic Beanstalk, we can deploy, monitor, and scale an application quickly
and easily.
AWS Elastic Beanstalk is an orchestration service offered from Amazon Web
Services for deploying infrastructure which orchestrates various AWS services,
including EC2, S3, Simple Notification Service (SNS), CloudWatch, autoscaling,
and Elastic Load Balancers.
AWS Elastic Beanstalk supports the following languages and development
stacks:
• Apache Tomcat for Java applications
Naresh i technologies Amazon Web Services Avinash Reddy T
2. You can simply select the Create application option to perform the
deployment and selecting the appropriate configuration for our instances.
3. If you want to customize each and every step, as you required, Select
Configure more options option.
• Then we’ll get three options for Configuration presets
i. Low Cost (Free Tier eligible)
ii. High Availability
iii. Custom Configuration
7. Status of Instance creation, and all the required resources are provisioning
by Elastic BS i.e; Security group, EIP, EC2, S3, Simple Notification Service
(SNS), CloudWatch, autoscaling, and Elastic Load Balancers.
Naresh i technologies Amazon Web Services Avinash Reddy T
11. If you made any changes to your existing code, you can zip it and
upload it.
12. Here is the illustration diagram of workflow
13. If you want to terminate the environment, select the Actions option
in Top right corner, then choose Terminate Environment.