if($build_config_instance){
my $host = 'root@' . $instance->dns_name();
my $scp = "scp -i $pvt_key $base_path/$build_script $host:/root/";
print STDERR "\nssh -i $pvt_key $host chmod +x /root/$build_script \n";
print STDERR "ssh -i $pvt_key $host /root/$build_script \n";
`$scp`;
`ssh -i $pvt_key $host chmod +x /root/$build_script `;
`ssh -i $pvt_key $host /root/$build_script `;
}
####
Oct 4 02:15:51 svrname S70ec2-get-credentials: New ssh key added to /root/.ssh/authorized_keys from http://169.254.169.254/1.0/meta-data/pub
lic-keys/0/openssh-key
Oct 4 02:15:52 svrname S71ec2-run-user-data: Retrieving user-data
Oct 4 02:15:52 svrname S71ec2-run-user-data: Skipping user-data as it does not begin with #!
##
##
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Net::Amazon::EC2;
use MIME::Base64;
my $ec2 = Net::Amazon::EC2->new(
AWSAccessKeyId => 'not-telling',
SecretAccessKey => 'not-telling-this-either' );
my $custom_ami_id = 'ami-ff46a796';
my $user_data = encode_base64('/home/hesco/sandbox/EC2/trick_out_my_server.sh');
if($create_new_instance){
my $instance = $ec2->run_instances(
'Placement.AvailabilityZone' => 'us-east-1a',
KeyName => 'aws_test',
SecurityGroup => 'asterisk',
ImageId => $custom_ami_id,
UserData => $user_data,
MinCount => 1,
MaxCount => 1 );
print STDERR Dumper($instance);
}
##
##
#!/bin/bash
set -e -x
apt-get --yes update
apt-get --yes upgrade
apt-get --yes install subversion build-essential etc . . .