1 package Oyster::Provision::AmazonEC2;
6 has 'api_username' => ( is => 'ro', isa => 'Str', required => 1, lazy_build => 1);
7 sub _build_api_username {
9 return $ENV{CLOUDSERVERS_USER} if exists $ENV{CLOUDSERVERS_USER};
10 die "Need api_username or CLOUDSERVERS_USER in environment";
13 has 'api_password' => ( is => 'ro', isa => 'Str', required => 1, lazy_build => 1);
14 sub _build_api_password {
16 return $ENV{CLOUDSERVERS_KEY} if exists $ENV{CLOUDSERVERS_KEY};
17 die "Need api_password or CLOUDSERVERS_KEY in environment";
20 has ec2_oyster_key => (is => 'rw', isa => 'Str', default => "OysterDefault");
25 my $ec2 = Net::Amazon::EC2->new(
26 AWSAccessKeyId => $self->api_username,
27 SecretAccessKey => $self->api_password,
30 my $key_pairs = $ec2->describe_key_pairs({ KeyName => $self->ec2_oyster_key });
32 unless(defined($key_pairs)) {
34 printf("Creating %s pair\n", $self->ec2_oyster_key);
35 $ec2->create_key_pair({ KeyName => $self->ec2_oyster_key });
45 # Start 1 new instance from AMI: ami-XXXXXXXX
46 my $instance = $self->ec2->run_instances(
47 ImageId => $self->image() || "ami-be6e99d7",
48 KeyName => $self->ec2_oyster_key,
72 Oyster::Provision::AmazonEC2 -- Provision your Oyster on Amazon EC2
76 Use the Amazon backend on your Oyster configuration file
78 =head1 REQUIRED PARAMETERS
80 The following are required to instantiate a backend:
86 The name of your new/existing rackspace server.
90 This is a key name to pass to EC2
94 The size ID of the rackspace server you want to create.
95 Use the following incantation to see them:
97 perl -MNet::RackSpace::CloudServers -e'
98 $r=Net::RackSpace::CloudServers->new(
99 user=>$ENV{CLOUDSERVERS_USER},
100 key=>$ENV{CLOUDSERVERS_KEY},
103 { "id $_->{id} ram $_->{ram} disk $_->{disk}\n" }
104 $r->get_flavor_detail
108 id 3 ram 1024 disk 40
109 id 4 ram 2048 disk 80
110 id 5 ram 4096 disk 160
111 id 6 ram 8192 disk 320
112 id 7 ram 15872 disk 620
116 The image ID of the rackspace server you want to create.
117 Use the following incantation to see them:
119 perl -MNet::RackSpace::CloudServers -e'
120 $r=Net::RackSpace::CloudServers->new(
121 user=>$ENV{CLOUDSERVERS_USER},
122 key=>$ENV{CLOUDSERVERS_KEY},
125 { "id $_->{id} name $_->{name}\n" }
128 id 29 name Windows Server 2003 R2 SP2 x86
129 id 69 name Ubuntu 10.10 (maverick)
130 id 41 name Oracle EL JeOS Release 5 Update 3
131 id 40 name Oracle EL Server Release 5 Update 4
132 id 187811 name CentOS 5.4
133 id 4 name Debian 5.0 (lenny)
134 id 10 name Ubuntu 8.04.2 LTS (hardy)
135 id 23 name Windows Server 2003 R2 SP2 x64
136 id 24 name Windows Server 2008 SP2 x64
137 id 49 name Ubuntu 10.04 LTS (lucid)
138 id 14362 name Ubuntu 9.10 (karmic)
139 id 62 name Red Hat Enterprise Linux 5.5
143 id 31 name Windows Server 2008 SP2 x86
144 id 51 name CentOS 5.5
145 id 14 name Red Hat Enterprise Linux 5.4
146 id 19 name Gentoo 10.1
147 id 28 name Windows Server 2008 R2 x64
148 id 55 name Arch 2010.05
150 Oyster only supports Linux images, specifically
151 Ubuntu 10.10 (maverick).
155 The public ssh key you would like copied to the
156 new server's C</root/.ssh/authorized_keys> file
157 to allow you to ssh in the box without providing