${Markup(_('Fedora Project - Creating an EC2 Fedora Instance.'))}

${Markup(_('← Back to the main \'Using Fedora\' page.'))}

${_('Create a Fedora Amazon EC2 Instance')}

${_('This quick and easy tutorial will show you how to create a Fedora EC2 instance.')}

${_('Preparations')}

${Markup(_('This tutorial assumes you already have an AWS account. AWS is not a free service - it is designed as a pay-as-you-go online service. You can learn more about pricing at <a href="%s">http://aws.amazon.com/ec2/pricing/</a>') % 'http://aws.amazon.com/ec2/pricing/')}

${_('In this tutorial, we will use euca2ools, a suite of command line tools designed for services like EC2. You can install it simply by typing:')}

yum install euca2ools

${_('To use the command line tools you first need to obtain access keys for your account.')} ${Markup(_('You can find them by going to the AWS management console on the web, clicking your name on the top, followed by <strong>Security Credentials</strong>, and scrolling down to the section titled <strong>Access Credentials</strong>.'))}
${Markup(_('Make note of the <strong>Access Key ID</strong> and the <strong>Secret Access Key</strong> that appears beside it. Both of them should be long sets of alphanumeric characters. Create a file called <code>.iamrc</code> in your <strong>home directory</strong> that contains those keys in this format:'))}

AWSAccessKeyId=${_('your_access_key_id')}
AWSSecretKey=${_('your_secret_key')}

${Markup(_('Since euca2ools is designed to work with all AWS-compatible clouds, not just AWS itself, it needs to know which cloud to contact. Create a file called <code>.eucarc</code> in your home directory with the following content to point it toward AWS:'))}

export AWS_CREDENTIAL_FILE=~/.iamrc
export EC2_URL=https://ec2.amazonaws.com/
export S3_URL=https://s3.amazonaws.com/
export EUARE_URL=https://iam.amazonaws.com/
source "$$AWS_CREDENTIAL_FILE"
export EC2_ACCESS_KEY=$$AWSAccessKeyId
export EC2_SECRET_KEY=$$AWSSecretKey
export AWS_ACCESS_KEY=$$AWSAccessKeyId
export AWS_SECRET_ACCESS_KEY=$$AWSSecretKey

${_('Finally, add these settings to your shell\'s environment by running:')}

$ source ~/.eucarc

${_('Choose an EC2 server')}

${Markup(_('Choose an EC2 region to use. Things to consider when choosing a region include its geographic location, the pricing for instances in that region, and whether the image you wish to use is available in that region. You can get a list of regions by running <code>euca-describe-regions</code>, which results in a list such as this:'))}

eu-west-1 ec2.eu-west-1.amazonaws.com
us-east-1 ec2.us-east-1.amazonaws.com
ap-northeast-1 ec2.ap-northeast-1.amazonaws.com
us-west-1 ec2.us-west-1.amazonaws.com
ap-southeast-1 ec2.ap-southeast-1.amazonaws.com

${Markup(_('When you choose an EC2 region you can make euca2ools start using it by editing the line that contains <code>EC2_URL</code> in your <code>.eucarc</code> file.'))}

$ export EC2_URL=https://ec2.us-east-1.amazonaws.com/

${Markup(_('...and then re-set the settings in your shell\'s environment:'))}

$ source ~/.eucarc

${_('Creating a key pair')}

${Markup(_('The primary way of logging into Fedora instances is via SSH. Since Fedora instances have no passwords, you need a SSH <em>key pair</em> to log in to them. The private half of this key pair is stored on your computer, while the public half is stored in EC2 so instances can download them as they start. This allows you to securely log into your instances without a password.'))}

${_('You can have multiple key pairs. Each key pair has its own name. Key pairs are specific to each EC2 region.')}

${Markup(_('Choose a name for a new key pair and then use the <code>euca-create-keypair</code> command to create it and write the private key to a file. Be sure to choose a name that is easy to remember.'))}

$ euca-create-keypair mykey > mykey.pem

${_('Note:')} ${Markup(_('Key pairs are irreplaceable|EC2 does not store the private halves of key pairs. The time you run <code>euca-create-keypair</code> is the only chance you will have to save a copy of the private key. There is no way to recover a lost private key from EC2.'))}

${Markup(_('You can use <code>euca-describe-keypairs</code> to display a list of your keypairs.'))}

$ euca-describe-keypairs
KEYPAIR mykey1 7b:9b:33:cf:bf:12:4d:62:b6:7c:fa:02:f2:f7:bc:59:e3:7e:40:fb
KEYPAIR mykey2 f9:93:1e:73:4b:2e:c1:0d:7f:79:e1:bc:c0:d0:7c:95:32:55:b7:dd

${Markup(_('You can use <code>euca-delete-keypairs</code> to delete a keypair. Deleting a keypair does not remove it from instances that are already running; it merely prevents new instances from using it.'))}

$ euca-delete-keypair mykey1

${_('Run an instance')}

${Markup(_('Run a new instance of the image and instance type you chose with <code>euca-run-instances</code>. To be able to log into the new instance, you must also specify the name of the key pair you created earlier. For example, to run a <code>t1.micro</code> instance of the image <code>ami-7f5a063a</code> with a key pair named <code>mykey</code>, run the following command:'))}

$ euca-run-instances ami-7f5a063a -t t1.micro -k mykey
RESERVATION r-4d5ea00a 0123456789ab default
INSTANCE i-910fbbd6 ami-7f5a063a pending 0 mykey t1.micro 2011-10-11T00:00:00.000Z us-east-1c aki-9ba0f1de

${Markup(_('The output of <code>euca-run-instances</code> contains the ID of the instance you just started. In the example above, the instance\'s ID is <code>i-910fbbd6</code>. You will need this ID to use tools that need to refer to the instance.'))}
${Markup(_('You can also find the various AMI-IDs for Fedora images for all regions <a href="http://fedoraproject.org/get-fedora#clouds">here</a>.'))}

${Markup(_('The instance starts in the <code>pending</code> state. When it finished booting it changes to the <code>running</code> state. When you terminate it it changes to the <code>shutting-down</code> and finally <code>terminated</code> states.'))}

${_('Log into the instance')}

${Markup(_('As the instance starts it obtains an IP address from EC2 and changes to the <code>running</code> state. You can check on your instances by running <code>euca-describe-instances</code>, optionally with the ID of the instance in question. When the instance is ready (or nearly ready) to use, <code>euca-describe-instances</code> will display the address you can use to log into it:'))}

$ euca-describe-instances
RESERVATION r-4d5ea00a 0123456789ab default
INSTANCE i-910fbbd6 ami-7f5a063a ec2-204-236-168-22.us-east-1.compute.amazonaws.com ip-10-170-15-23.us-east-1.compute.internal \
running 0 mykey t1.micro 2011-10-11T00:00:00.000Z us-east-1c aki-9ba0f1de

${Markup(_('The public address of the instance in this example is <code>ec2-204-236-168-22.us-east-1.compute.amazonaws.com</code>. Other useful bits of information from this command include the availability zone in which the instance is running (<code>us-east-1c</code>) and the time that the instance started.'))}

${Markup(_('Once the instance is <code>running</code> you can log into it with <code>ssh</code>. On Fedora\'s images you should log in as <strong>fedora</strong> user:'))}

$ ssh -i mykey.pem fedora@ec2-204-236-168-22.us-east-1.compute.amazonaws.com
[fedora@i-910fbbd6 ~]$ cat /etc/fedora-release
Fedora ${_('release 20 (Heisenbug)')}

${_('You can now use the instance as you would use any other computer running Fedora.')}

${Markup(_('When you finish using the instance you should terminate it with <code>euca-terminate-instances</code> to free up resources and reduce costs:'))}

$ euca-terminate-instances i-910fbbd6

${_('Enjoy and share!')}

${_('Now you know how to setup a Fedora EC2 Instance! Have fun, and be sure to share these tips you learned with others!')}

${Markup(_('&#8592; Read about more ways to use Fedora!'))}