Showing posts with label elb. Show all posts
Showing posts with label elb. Show all posts

Sunday, June 22, 2014

ELB Health Check return code

You can have TCP and HTTP health checks. A TCP health check will simply check if the web page exists (can be pinged essentially) a HTTP health check needs to return a 200 to pass the health check. More can be found here:
http://stackoverflow.com/questions/23689333/how-to-instruct-an-aws-elb-to-consider-a-health-check-that-returns-a-403-code-as

AWS ELB instances tied to ELB and ip addresses

The Amazon Elastic Load Balancer takes care of scaling out the number of underlying EC2 instances that make up the software virtual load balancer that is the Amazon ELB. However, you may want to determine the number of instances that are servicing your requests if you plan to scale out the number of users for a large promotion or for processing of a large number of users.  Determining the number of underlying instances is easy. You can simply use the host or dig commands using the ELB DNS name. There will be a minimum of one EC2 instance for each AZ that the ELB is servicing.

1. [ec2-user@ip-10-0-0-50 ~]$host ReachForceAutoScalingELB-1342887266.us-west-2.elb.amazonaws.com
ReachForceAutoScalingELB-1342887266.us-west-2.elb.amazonaws.com has address 50.112.140.192
ReachForceAutoScalingELB-1342887266.us-west-2.elb.amazonaws.com has address 50.112.183.144


2. [ec2-user@ip-10-0-0-50 ~]$ dig ReachForceAutoScalingELB-1342887266.us-west-2.elb.amazonaws.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.28.amzn1 <<>> ReachForceAutoScalingELB-1342887266.us-west-2.elb.amazonaws.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 813
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;ReachForceAutoScalingELB-1142887282.us-west-2.elb.amazonaws.com. IN A

;; ANSWER SECTION:
ReachForceAutoScalingELB-1342887266.us-west-2.elb.amazonaws.com. 30 IN A 50.112.183.144
ReachForceAutoScalingELB-1342887266.us-west-2.elb.amazonaws.com. 30 IN A 50.112.140.192

;; Query time: 1 msec
;; SERVER: 10.0.0.2#53(10.0.0.2)
;; WHEN: Fri Jun  6 12:31:34 2014
;; MSG SIZE  rcvd: 113

Monday, March 31, 2014

AWS Elastic Beanstalk basics

When first getting started with AWS Elastic Beanstalk here are some basic things to know
1. Logging : In Java, logging is done using the Apache Commons Logging framework. Logs can be captured with Apache Log4j or any other component that supports Apache Commons Logging.
2. Custom AMIs can be used : The process is documented here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html
3. RDS support: Amazon RDS Oracle, MySQL and SQL Server databases can deployed as part of you Elastic Beanstalk application. 
4. Launch New Environment to get OS patches : Amazon periodically updates the AMIs that were used to build the server instances, but servers can’t be updated while their running. When you launch a new environment, you get the updates.
5. Load Balancing : The Elastic Beanstalk service creates the load balancer for you.
6. Auto Scaling : The service creates the auto scaling configuration and group for you.
7..Custom configuration : Example Uses for YAML Configuration 

  • Define custom environment variables beyond PARAMx
  • Identify files to be downloaded to hosts 
  • Can automatically unpack downloaded archive files
  • Specify software to install Specify which services should run on hosts 
  • Create and run scripts 
  • Create and configure AWS resources

Thursday, December 5, 2013

Migrate EC2 instance from EC2-Classic account to EC2-VPC account

Here is the process to move a one EC2 instance from an EC2-Classic account to an EC2-VPC default account.

Create VPC
Note: since this is a new account, it will have a VPC by default. It will have one VPC, 3 subnets, 1 Network ACL, 1 Internet Gateway, 1 Route table by default. vpc-bb55bbd0 is the default VPC. 

We can use the default VPC or create a new one as well.

1. Create the VPC

a.     Click the Your VPCs link
b.     Click the Create VPC button. (you will see your default VPC already created)
Note the VPC ID: vpc-e7262c85
c.     In the Create   VPC dialog box, enter a CIDR Block of 10.50.0.0/16.



d.     Click Yes, Create.
2 .     Create four subnets : two public and two private subnet. Want to so we can have a  Active-passive failover scenario. We will only use the two public subnets to start as there is no database back end.
Create Public Subnet in First AZ
a.     Select the Subnets link from the left hand menu.
b.     Click the Create Subnet button.



c.     Ensure that the VPC is set to the one created earlier.
d.     Choose an Availability Zone.
e.     Specify a CIDR Block of 10.50.1.0/24.
f.      Click Yes, Create.
Note : First public subnet: subnet-599d963b
3. Create Public Subnet in Second AZ
a.     Select the Subnets link from the left hand menu.



b.     Click the Create Subnet button.
c.     Ensure that the VPC is set to the one created earlier.
d.     Choose an Availability Zone.
e.     Specify a CIDR Block of 10.50.2.0/24.
f.      Click Yes, Create.
Note : Second public subnet: subnet-10714464

4. Create first private Subnet in First AZ
a.     Select the Subnets link from the left hand menu.
b.     Click the Create Subnet button.



c.     Ensure that the VPC is set to the one created earlier.
d.     Choose an Availability Zone.
e.     Specify a CIDR Block of 10.50.10.0/24.  (I jumped up to 10 to give more room for public subnet expansion on first AZ and started with 10 so all subnets in first AZ start with one).
f.      Click Yes, Create.
Note : First private subnet: subnet-389d965a

5. Create second private Subnet in second AZ
a.     Select the Subnets link from the left hand menu.
b.     Click the Create Subnet button.

c.     Ensure that the VPC is set to the one created earlier.
d.     Choose an Availability Zone.
e.     Specify a CIDR Block of 10.50.20.0/24.  (I jumped up to 10 to give more room for public subnet expansion on first AZ and started with 10 so all subnets in first AZ start with one).
f.      Click Yes, Create.
Note : Second private subnet: subnet-fe71448a


6.     Create Internet Gateway
a.     First step: Create Internet Gateway
b.     Then attach to VPC
Created : igw-9d0903ff
4.     Create route table for public subnet. Note: We will not create one for the private subnets at this time as no instances in them.
a.     Create a route table for the VPC


b.     Add the public route to the internet gateway to the route table



                                               i.     Add a route with a Destination of 0.0.0.0/0 and with Target set to the Internet Gateway.

c.      Associate the First public subnet: subnet-599d963b to the route table

d.     Associate the Second public subnet: subnet-10714464 to the route table


58.     Create Elastic IP : 54.201.96.147
69.     Create Security groups : ELB, WebTier
a.     ELB : Add a rule that allows TCP port 80 (HTTP) from 0.0.0.0/0 (everywhere, including the Internet). sg-c8a3b5aa



b.     WebTier  sg-58adbb3a



710.     No need to create NAT and route NAT to the Internet Gateway as have nothing in private subnet at this time.



Create ELB



1. Create ELB


2. Add health check



13.     Add subnets and security groups







Launch Instance


1.     Could not use the AMI from the old account as was not valid. 
2.     Launched instance from AMI eligble for free tier.
3.     Created snapshot of EBS root volume in old account
4.     Gave permissions on new account to snapshot – snap-8fd359b4
5.     aws ec2 describe-snapshots --snapshot-ids snap-8fd359b4
6.     aws ec2 create-volume --snapshot-id snap-8fd359b4 --size 8 --availability-zone us-west-2a
7.     aws ec2 describe-volumes --volume-ids vol-41a11c68
8.     aws ec2 stop-instances --instance-id i-c12ca6f7
9.     aws ec2 detach-volume --volume-id vol-2ba51802
10.  aws ec2 attach-volume --volume-id vol-41a11c68 --instance-id i-c12ca6f7 --device /dev/sda1
11. aws ec2 start-instances --instance-id i-c12ca6f7
13. need to attach to ELB. I did this in the console
14. Needed to start apache as forgot to include in user data: sudo /etc/init.d/httpd start
15. Test on Elastic IP address : 54.222.94.234 (worked so closed HTTP on instance for 0.0.0.0/0)
17. Test running instance before migrating route 53: LoadBalancer-788377229.us-west-2.elb.amazonaws.com

Migrate Route 53


1.     Create hosted zones
2.     Create record sets
3.     Go to your domain name registry (in this case godaddy) and launch (godaddy terminology) your domain name to set your Nameservers.  Use the four name services/delegation set retrieved in step 1.

Decommission the old account 

1.     Spin down EC2 instance
2.     Decommision Route 53
3.     Delete all EBS volumes and snapshots