Posts

AWS EC2 instance with custom security group rules

Image
Hello all, Today we are going to create an AWS EC2 instance with customized rules in security group that allow only specific hosts to connect to it and ping it. So first login to your AWS account and select a region where you want to create an EC2 instance. I am going to use Mumbai region (ap-south-1) . Next click on Launch instances button and below page will appear: Select any AMI [Amazon Machine Image] of your preferences, I am selecting  Amazon Linux 2 AMI . Then select the instance type from below webpage, I will choose t2.micro and click on Next button In instance details page either you can choose default values and click on Next or you can configure some options. I am selecting Subnet option as Default in ap-south-1a and clicking on Next button.   In Add Storage page give size as per your requirement. I'll go with the default option [8 GiB]. In the next page we can add tags to this instance so we can refer to this instance using this tags. We can add multiple ...

Create AWS EC2 instance with webserver installed using Ansible

Image
Hello all, in this blog we are going to learn how to provision/create/spawn an AWS EC2 instance using Ansible tool. We will make all the steps automatic so that our ec2 instance will be created and a webServer starts running without any manual intervention. We will write two ansible roles: One for creating aws ec2 instances with desired ingress port opening Another for installing and configuring apache webserver Go to ansible default role path . cd /etc/ansible/roles and create two ansible roles using below commands ansible-galaxy init ec2_instance ansible-galaxy init custom_webserver Paste the below content in ec2_instance/tasks/main.yml --- # tasks file for ec2_instance ######################################################## ##### Below file is required to login aws account ####### - include_vars: secure.yml ##################################################### ###### Creating a security group for ec2 instance ### - name: create a security group ec2_group: name:...