Joaquin Diez’s Weblog

Small notes…thoughts… etc..

Crear un AMI usando uno ya existente

Una forma muy comoda de crear nuevos AMIs en Amazon Ec2 es usar uno ya existente que te guste, modificarlo y configurarlo segun necesites. De esta forma puede ser probado bien y una vez te sientas cómodo con las modificaciones entonces convertir esa configuracion en un AMI nuevo que poder utilizar para tus proyectos.

Para poder hacer esto hay que seguir los siguientes pasos

PreRequisitos, esto lo he probado en un Ubuntu 9.04

  • iniciar una instancia usando el ami que desees en mi caso (ami-6686ae12 es un ami desplegado en la version Amazon Ec2 Europa)
  • instalar Java y definido JAVA_HOME

Instalar las utilidades  de Amazon


#!/bin/bash
apt-get update
apt-get install ruby rubygems libopenssl-ruby debootstrap dpkg rar unrar zip unzip
RDIR="`pwd`"
PREDIR=$RDIR/preproduccion
rm -d -f -r soft
mkdir soft
cd soft
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-ami-tools.zip
cd ec2-ami*
export EC2_AMITOOL_HOME="`pwd`"
cd ..
unzip ec2-api-tools.zip
cd ec2-api*
export EC2_HOME="`pwd`"
cd ..
cd ..
export PATH=$PATH:$EC2_HOME/bin:$EC2_AMITOOL_HOME/bin
export EC2_CERT={localizacion certificado Ec2}
export EC2_PRIVATE_KEY={localizacion private_key}
export EC2_USER_ID={user_id ec2}
export AWS_ACCESS_KEY={aws access key}
export AWS_SECRET_KEY={aws_secret_key}
export RUBYLIB=$RUBYLIB:/usr/lib/site_ruby/

Modificar he instalar en la imagen los paqueres que se consideren necesario…

por ejemplo apache2, openvpn, mysql.. lo que se quiera..

Crear el ami ejecutando las siguentes lineas

ec2-bundle-vol -r i386 -d /mnt -p {prefijo ficheros ami} -u $EC2_USER_ID -k $EC2_PRIVATE_KEY -c $EC2_CERT -s 10240 -e /mnt,/tmp,/root/.ssh,/mnt/ebs0
ec2-upload-bundle -b {nombre bucket S3} -m /mnt/{prefijo ficheros ami}.manifest.xml -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY --location EU
ec2-register --region eu-west-1 {nombre bucket S3}/{prefijo ficheros ami}.manifest.xml

agosto 12, 2009 Posted by | Cloud Computing, ec2, linux, Uncategorized | , , , , , | 2 comentarios

Amazon don’t know that Spain exists?

As some of you know I work for an spanish Start-Up called Unience (www.unience.com) we have been using Amazon AWS since late 2007 and we have deployed all our infraestructure on Amazon AWS services using  All of them!!! I am sure not to many companys can say the same….

Well, today Amazon announce the 3rd Annual AWS Start-Up Challenge, and again .. if you are Spanish..Portuguese … Italian… French (for example) you can’t enter in competition… only United States, United Kingdom, Germany, and Israel

Why only the companies from this countries can compite? What’s up?

this is the text they have send to their clients


Announcing the 3rd Annual AWS Start-Up Challenge
The AWS Start-Up Challenge has launched and once again we are looking for the most promising start-ups that are building their businesses on AWS infrastructure services. Start-ups in the United States, United Kingdom, Germany, and Israel are encouraged to apply for a chance to win $50,000 in cash, $50,000 in AWS credits, mentoring sessions from AWS technical experts, and AWS Premium Support Gold for one year.

The 2008 Challenge winner, John Barr, VP of Yieldex says, «Winning the AWS Start-Up Challenge last year put our business on the fast track. Since then, we’ve successfully raised $8.5 million dollars and grown at least two orders of magnitude in each of the data processing categories we measure, including 40 billion monthly impressions under management and 3 terabytes of data processed daily in the cloud.» To learn more and enter the competition, visit the AWS Start-Up Challenge home page.

julio 14, 2009 Posted by | Cloud Computing, ec2 | , , , , | Deja un comentario

Nuevos Planes de Precios de Amazon

Acabo de leer en el Twitter de Jeff Barr (Evangelista de Amazon AWS) que Amazon acaba de introducir nuevos planes de precios paara la reserva de Instancias con el Objetivo de ayudar a reducir costes a aquellos clientes, que mantienen una plataforma estable de instancias levantadas.

Aqui podeis ver en detalle el plan de precios http://aws.typepad.com/aws/2009/03/announcing-ec2-reserved-instances.html

Han definido 2 planes de precios, con reservas a 1 año y a 3 años, en los cuales pagas una tarifa inicial de reserva y luego pagas el coste por hora de maquina levantada en vez de a 0.1$ a 0.03$.

¿Cuanto ahorro supone esto?

Plan 1 año = 288,2$ anuales si la maquina esta levantada (24×7)

Plan 3 años= 446,5$ anuales si la maquina esta levantada (24×7)

Claramente merece la pena, si estimas tener levantadas N maquinas de forma estable..

Y ahora la mala noticia para los Europeos… de momento solo estara disponible este plan para las reservas echas en los CPD de USA, asi que los que deseamos tener las maquinas en Europa no podremos acceder a estos precios aun…es una pena que siempre nos dejen para el final.

De todas formas, este tipo de pasos que esta dando amazon me reafirman en la idea del uso de Cloud Computing sobre todo para empresas que estan empezando, como en Unience, y en una forma magnifica de controlar gasto en tu infraestructura.

marzo 12, 2009 Posted by | Cloud Computing, ec2 | , , , , , | 1 comentario

CapGemini partner de Amazon AWS

http://www.capgemini.com/services/outsourcing/infrastructure-management/cloud-computing/

Pues segun he podido enterarme a través de Twitter de Jeff Barr , evangelista Jefe de Amazon AWS,  Cap Gemini se ha convertido en en partner suyo para consultoria a empresas sobre Amazon AWS.

Creo que este campo de consultoria y de dar soluciones a empresas para el uso de lso diversos Cloud, es algo que va a ser un mercado y negocio sin duda a explotar.

Pero no lo veo tan claro aun para grandes empresas, y si para multitud de pequeñas y medianas empresas asi como Start-Ups, ya que creo que Amazon AWS esta plenamente pensada para ellas, y para ese tipo de proyectos de Fire&Forget, es decir, lanzarlos durante un tiempo y luego olvidarte de ellos..

veremos como evoluciona.. pero que tal una consultora adecuada para Pymes? CapGemini no lo es..

logocap

noviembre 19, 2008 Posted by | Cloud Computing, ec2 | , , , | Deja un comentario

Amazon Ec2: Configurando Linux(Debian,Ubuntu)

PreCondicion: Tener JAVA_HOME configurado correctamente.

Una vez que te has dado de alta como usuario de Amazon WebServices y como usuarios de Amazon Ec2, llega el momento el configurar el entorno para poder hacer uso de sus APIS y comandos.

Amazon va continuamente actualizando sus APIS para ampliar funcionalidades, por lo que necesitaba algo que me permitiera estar siempre con la ultima version disponible en el sistemas.

EL siguiente script hace todo lo necesario para desde cero poder tener tu sistema listo para interactuar con los servicios de Amazon Ec2.


#!/bin/bash
sudo apt-get install ruby rubygems libopenssl-ruby debootstrap dpkg

RDIR=»`pwd`»
PREDIR=$RDIR/mydir
rm -d -f -r soft
mkdir soft
cd soft
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-ami-tools.zip
cd ec2-ami*
export EC2_AMITOOL_HOME=»`pwd`»
cd ..
unzip ec2-api-tools.zip
cd ec2-api*
export EC2_HOME=»`pwd`»
cd ..
cd ..
export EC2_CERT=$PREDIR/cert-MYCERTIFICADO-GENERADO-POR-AMAZON.pem
export EC2_PRIVATE_KEY=$PREDIR/pk-PRIVATE-KEY-GENERADA-POR-AMAZON.pem
export EC2_USER_ID=MI-NUMERO-DE-USUARIO

export PATH=$PATH:$EC2_HOME/bin:$EC2_AMITOOL_HOME/bin
export AWS_ACCESS_KEY=MY-ACCESS-KEY
export AWS_SECRET_KEY=MY-SECRET-KEY

export EC2_GSG_KEYPAIR=my-keypair
export UPLOAD_BUCKET_NAME=se-uploaf-bcket
export RUBYLIB=$RUBYLIB:/usr/lib/site_ruby/

guarda el código anterior en un fichero llamado por ejemplo config-ec2.sh y dale permisos de ejecucion con

chmod +x config-ec2.sh

luego:

source config-ec2.sh

una vez se ejecute si todo ha ido bien prueba a escribir el siguiente comando.

ec2-describe-images --all

si te aparece la lista de Amis disponibles.. enhorabuena ya puedes empezar a disfrutar de esta herramienta revolucionaria que es Amazon EC2

agosto 31, 2008 Posted by | desarrollo, ec2, linux, ruby | , , , , , | Deja un comentario

Launching an EC2 image….

  1. Launch the ami selected .. in this case I am using and Fedora 8 base I have design for testing.. this image will be available for public use shortly.
    ec2-run-instances ami-62dc390b -k gsg-keypair When the command finish we get the instance-id Amazon assigned us
  2. Now we need to see the state of our instace for that we make
    ec2-describe-instance When executing this command we get something likeRESERVATION r-fdd13994 595199202159 default
    INSTANCE i-debf4eb7 ami-62dc390b ec2-67-202-32-41.compute-1.amazonaws.com domU-12-31-38-00-40-15.compute-1.internal
    running gsg-keypair 0 m1.small 2007-12-19T20:39:02+0000
    We are ready to connect with the instance.
  • Autorize Network Access
  • ec2-authorize default -p 22
    ec2-authorize default -p 80
    <Opening this ports we can now access it throw SSH and configure the machine as we need

  • Revoke Network Access
  • ec2-revoke default -p port

    We can find more information about this in http://developer.amazonwebservices.com/connect/entry.jspa?externalID=992&categoryID=87

    diciembre 19, 2007 Posted by | desarrollo, ec2 | | Deja un comentario

    Problems with Ec2 tools and Ruby 1.8.6

    When you try to bundle and Ec2 image using the next command,

    ec2-bundle-image -i /mnt/image/$IMAGE_NAME -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $AWS_ACCOUNT_NUMBER

    and you have just installed the last version of Ruby 1.8.6, is possible you get the next error:


    Creating bundle manifest...
    Error: private method `gsub' called for 51:Fixnum
    ec2-bundle-image failed.

    This error can be fixed in this way,

    go to the instalation of ruby in your system and open /usr/lib/ruby/1.8/rexml/text.rb

    This could have been fixed at the rcov side, but since it *did* used to work
    with rexml, I consider this a backwards-compatibility failure. The fix is
    trivial:

    --- rexml/text.rb.orig 2007-10-22 08:00:04.000000000 +0100
    +++ rexml/text.rb 2007-10-22 08:00:33.000000000 +0100
    @@ -286,7 +286,7 @@
    EREFERENCE = /&(?!#{Entity::NAME};)/
    # Escapes all possible entities
    def Text::normalize( input, doctype=nil, entity_filter=nil )
    - copy = input
    + copy = input.to_s
    # Doing it like this rather than in a loop improves the speed
    #copy = copy.gsub( EREFERENCE, '&' )
    copy = copy.gsub( "&", "&" )

    (Note that there are other places in this file which might benefit from a
    to_s as well)

    The second is almost certainly a bug in REXML: it’s a misnamed local
    variable.

    --- rexml/document.rb.orig 2007-10-22 08:02:36.000000000 +0100
    +++ rexml/document.rb 2007-10-22 08:03:01.000000000 +0100
    @@ -183,7 +183,7 @@
    output = Output.new( output, xml_decl.encoding )
    end
    formatter = if indent > -1
    - if transitive
    + if trans
    REXML::Formatters::Transitive.new( indent, ie_hack )
    else
    REXML::Formatters::Pretty.new( indent, ie_hack )

    noviembre 29, 2007 Posted by | desarrollo, ec2, linux, ruby | , , | Deja un comentario