Thursday, September 17, 2015

Amazon Web Services

AWS main components:
  1. S3 (Simple storage service)
  2. SQS (Simple Queue Service)
  3. EC2 (Elastic Compute Cloud)
  4. Elastic Beanstalk - PaaS
  5. EBS (Elastic Block Store) - block storage
    1. Instance store-based AMIs - are similar to ephemeral boot drive of openstack.
  6. CloudFormation - orchestration tool (like puppet) from Amazon similar to Heat for OpenStack
  7. CloudFront - CDN feature of Amazon Web services cloud
  8. ELB (Elastic Load Balancer)
  9. Amazon DynamoDB - NoSQL DB from Amazon

S3 - containers (called buckets) - object storage
For eg. Netflix uses S3 to store movies which are then streamed to their customers.



Using AWS CLI: - 

Installing on Mac/Linux is pretty easy if you already have pip installed:
$ pip install awscli

To get started and create an ubuntu instance all using the CLI:

  1. Create a key pair to use for accessing the VM
$ aws ec2 create-key-pair --key-name watshkeydev --query 'KeyMaterial' --output text > watshkeydev.pem
$ chmod 400 watshkeydev.pem

  1. Create security group and create a rule in the group to allow your CIDR subnet address or single IP to access the VM. With 0.0.0.0/0 we allow any host to be able to connect which is fine for test setup as we still require the private key to be able to ssh to VM.
$ aws ec2 create-security-group --group-name devenv-sg --description "security group for development environment in EC2"
$ aws ec2 authorize-security-group-ingress --group-name devenv-sg --protocol tcp --port 22 --cidr 0.0.0.0/0

  1. Launch the VM instance
$ aws ec2 run-instances --image-id ami-29ebb519 --count 1 --instance-type t2.micro --key-name devenv-key --security-groups devenv-sg --query 'Instances[0].InstanceId'
"i-b0b0ac89"

The image id is that of Ubuntu 14.04.1 Trusty release.
This step will take some time so wait and in between if you want yoy can poll for the VM status with the following command:

 $ aws ec2 describe-instances --instance-ids i-b0b0ac89 --query 'Reservations[0].Instances[0].State.Name'
"running"

Once it is running proceed to the next step.

  1. Connect to the VM
$ aws ec2 describe-instances --instance-ids i-b0b0ac89 --query 'Reservations[0].Instances[0].PublicIpAddress'
"x.y.z.k"

$ ssh -i watshkeydev.pem ubuntu@x.y.z.k

  1. Start/stop the instance remotely
$ aws ec2 stop-instances --instance-ids i-b0b0ac89

$ aws ec2 start-instances --instance-ids i-b0b0ac89

No comments:

Popular micro services patterns

Here are some popular Microservice design patterns that a programmer should know: Service Registry  pattern provides a  central location  fo...