Thursday, July 2, 2015

ELB CLI Commands

  1. Create internal load balancer aws elb create-load-balancer --load-balancer-name myelbname --listeners Protocol=HTTP,LoadBalancerPort=80,InstanceProtocol=HTTP,InstancePort=9080 --subnets mysubnet1-in-useast1a mysubnet2-in-useast1c--scheme internal --tags Key=environment,Value=stage Key=project,Value=myproject Key=app,Value=myapp Key=product,Value=elb 

  2. Update application generated cookie stickiness aws elb create-app-cookie-stickiness-policy --load-balancer-name myelbname --policy-name myapp-cookie-policy --cookie-name JSESSIONIDX aws elb set-load-balancer-policies-of-listener --load-balancer-name myelbname --load-balancer-port 80 --policy-names myapp-cookie-policy

  3. Update internal load balancer attributes (Combined - CrossZoneLoadBalancingAccessLogsConnectionSettingsConnectionDraining) 
aws elb modify-load-balancer-attributes --load-balancer-name myelbname --load-balancer-attributes {\"CrossZoneLoadBalancing\":{\"Enabled\":true},\"AccessLog\":{\"Enabled\":true,\"S3BucketName\":\"myelblogs\",\"S3BucketPrefix\":\"myapp\",\"EmitInterval\":5},\"ConnectionSettings\":{\"IdleTimeout\":60},\"ConnectionDraining\":{\"Enabled\":true,\"Timeout\":300}}  

# Individual Commands 
# Update load balancer attributes - CrossZoneLoadBalancing aws elb modify-load-balancer-attributes --load-balancer-name myelbname --load-balancer-attributes {\"CrossZoneLoadBalancing\":{\"Enabled\":true}} 

# Update internal load balancer attributes - AccessLogs aws elb modify-load-balancer-attributes --load-balancer-name myelbname --load-balancer-attributes {\"AccessLog\":{\"Enabled\":true,\"S3BucketName\":\"myelblogs\",\"S3BucketPrefix\":\"myapp\",\"EmitInterval\":5}} 

# Update internal load balancer attributes - ConnectionSettings aws elb modify-load-balancer-attributes --load-balancer-name myelbname --load-balancer-attributes "{\"ConnectionSettings\":{\"IdleTimeout\":60}}" 

# Update internal load balancer attributes - ConnectionDraining aws elb modify-load-balancer-attributes --load-balancer-name myelbname --load-balancer-attributes "{\"ConnectionDraining\":{\"Enabled\":true,\"Timeout\":300}}"

Monday, September 29, 2014

SSL upload

Upload

aws iam upload-server-certificate --server-certificate-name mycertname --certificate-body file://mycert.cer --private-key file://mycert.key

or

aws iam upload-server-certificate --server-certificate-name mycertname --certificate-body file://mycert.cer --private-key file://mycert.key  --certificate-chain file://certificate_chain_file

Verify

aws iam get-server-certificate --server-certificate-name mycertname


Commands to convert .crt and .key to .pem
openssl rsa -in server.key -text > my-private-key.pem
openssl x509 -inform PEM -in server.crt > my-private-cert.pem

Setup Amazon RDS CLI on Windows


Download RDSCLI.zip from http://aws.amazon.com/developertools/2928
Extract  the zip file C:\......\RDSCli\RDSCli-1.15.001

Set the path
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55

setx AWS_CREDENTIAL_FILE C:\...\RDSCli\RDSCli-1.15.001\credential
(this file contains access keys)

setx AWS_RDS_HOME C:\...\RDSCli\RDSCli-1.15.001

setx PATH "%PATH%;%AWS_RDS_HOME%\bin"

> rds --help

Tuesday, September 16, 2014

Setup Amazon CLI on Windows

1. Download the AWS CLI MSI installer (AWSCLI64.msi) for Windows (64-bit) from https://s3.amazonaws.com/aws-cli/AWSCLI64.msi

2. Execute the default installation AWSCLI64.msi

3. Download python (python-3.4.1.amd64.msi) )from http://python.org/download

4. From windows command line, execute these commands
   > set PATH=%PATH%;C:\Python34
   > python --help
   > python -m pip install -U pip --proxy [user:password]@proxyserver:proxyport
   > pip --help
   > aws help
   > aws --version

5. Configure AWS
    > aws configure
       AWS Access Key ID [None]: enter-your-access-key-id-here
       AWS Secret Access Key [None]: enter-your-secret-access-key-here
       Default region name [None]: us-east-1
       Default output format [None]:

Friday, August 5, 2011

Creating and connecting to first EC2 UNIX instance

Login to AWS EC2
Once you sign up or EC2 account, login to AWS management console.
Select EC2 tab

Create Key Pair
From the navigation panel on the left, navigate to Network and Security section
Click on Key Pairs
Create new Key Pair. Provide name of your choice (eg: kpn1). A key pair name will be created. Fingerprint will be displayed on the key pair panel. A file will be downloaded to your desktop named kpn1.pem

Create Security Group
From the navigation panel on the left, navigate to Network and Security section
Click on Security Group
Create Security Group (eg: Name: sg1, Description: Security Group 1)

Create EC2 instance
  1. From the navigation panel, go to EC2 dashboard
  2. Click on Launch Instance button
  3. If you want to start with a new instance to play, select Basic 32-bit Amazon Linux AMI 2011.02.1 Beta
  4. In the next page, select Number of Instances - 1, Availability Zone - no preference, Instance Type: Micro. These are the defaults. Leave as it is. Continue.
  5. Leave  the defaults on Advance Instance Options - Continue
  6. On the key value panel, type in the key as 'Name' and value as 'Web Server' (you can label it appropriately based on your server type). Continue
  7. Select 'Choose from your existing key pair'. Select the value  kpn1 from the dropdown. Continue
  8. Select Security group sg1. Continue.
  9. Click on Launch Instance. This step will create your EC2 instance.

Locating your EC2 IP
Navigate to Instances.
Select the server and review the bottom panel.
Public DNS: ec2-XX-XX-XX-XXX.compute-1.amazonaws.com
ec2-XX-XX-XX-XXX.compute-1.amazonaws.com is your hostname.
XX.XX.XX.XXX is  your IP address

Connecting to your EC2 Instance as ec2-user
ssh ec2-user@ec2-instance-ipaddress –i {filepath}/privkey.pem

or

1) Convert .pem to .ppk format using puttygen
Download puttygen.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Execute puttygen
File -> Load Private Key -> Select kpn1.pem
You will get a prompt successfully imported foreign key.
File -> Save Private Key -> Save as kpn1.ppk

2)
Download putty.exe from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. This is a tool to connect to your ec2 unix instance.
Execute putty.exe
Session -> Host Name -> Type ec2 instance ip address
Navigate to Connection -> SSH - Auth -> Select the kpn1.ppk file
Open

3) Login as ec2-user

Connecting to your EC2 Instance as root
You still have to follow the steps to login as ec2-user
and then type command "sudo su"

Sunday, July 31, 2011

Change the time in EC2 instances

1) Backup /etc/localtime
2) ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Saturday, July 30, 2011

Sign up

Sign up for Amazon AWS.

Setting up a website in AWS require planning and decision making.

Try to understand the pricing model.