remove old Amazon EC2-related things since no one should ever deploy a mail server to EC2 (IPs have bad reputation)
This commit is contained in:
parent
511453adf7
commit
6d1d9e1cc9
|
@ -1,47 +0,0 @@
|
||||||
Deploying to EC2
|
|
||||||
================
|
|
||||||
|
|
||||||
Amazon's EC2 isn't a great place to host a mail server. For one, you don't know if you'll get an IP address with a bad reputation from its previous owner. Also, setting reverse DNS requires a special request. But EC2 makes deployment easy, so it may at least be useful for testing.
|
|
||||||
|
|
||||||
Instructions
|
|
||||||
------------
|
|
||||||
|
|
||||||
Sign up for Amazon Web Services.
|
|
||||||
|
|
||||||
Create an Access Key at https://console.aws.amazon.com/iam/home?#security_credential. Download the key and save the information somewhere secure.
|
|
||||||
|
|
||||||
Set up your environment and paste in the two parts of your access key that you just downloaded:
|
|
||||||
|
|
||||||
sudo apt-get install ec2-api-tools
|
|
||||||
|
|
||||||
export AWS_ACCESS_KEY=your_access_key_id
|
|
||||||
export AWS_SECRET_KEY=your_secret_key
|
|
||||||
export EC2_URL=ec2.us-east-1.amazonaws.com
|
|
||||||
export AWS_AZ=us-east-1a
|
|
||||||
|
|
||||||
Here we're using the Ubuntu 13.04 amd64 instance-store-backed AMI in the us-east region. You can select another at http://cloud-images.ubuntu.com/locator/ec2/.
|
|
||||||
|
|
||||||
Generate a new "keypair" (if you don't have one) that will let you SSH into your machine after you start it:
|
|
||||||
|
|
||||||
ec2addkey mykey > mykey.pem
|
|
||||||
chmod go-rw mykey.pem
|
|
||||||
|
|
||||||
Then launch a new instance. We're creating a m1.small instance --- it's the smallest instance that can use an instance-store-backed AMI. So charges will start to apply.
|
|
||||||
|
|
||||||
source ec2/start_instance.sh
|
|
||||||
|
|
||||||
It will wait until the instance is available.
|
|
||||||
|
|
||||||
You'll probably want to associate it with an Elastic IP. If you do, you'll need to update the INSTANCE_IP variable.
|
|
||||||
|
|
||||||
Log into the server:
|
|
||||||
|
|
||||||
ssh -i mykey.pem ubuntu@$INSTANCE_IP
|
|
||||||
|
|
||||||
Then follow the instructions in the main README.
|
|
||||||
|
|
||||||
If you were just testing and are ready to destroy your instance (and all data), run:
|
|
||||||
|
|
||||||
ec2-terminate-instances $INSTANCE
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
export VOLUME_SIZE=1 # in GiB (2^30 bytes)
|
|
||||||
ec2-create-volume -s $VOLUME_SIZE -z $AWS_AZ > volume.info
|
|
||||||
export VOLUME_ID=`cat volume.info | awk {'print $2'}`
|
|
||||||
export VOLUME_IS_NEW=1
|
|
||||||
echo Created new volume: $VOLUME_ID
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
if [ -z "$EC2_KEYPAIR_NAME" ]; then
|
|
||||||
EC2_KEYPAIR_NAME=mykey
|
|
||||||
fi
|
|
||||||
|
|
||||||
UBUNTU_CONFIG="us-east-1 13.04 amd64 instance-store"
|
|
||||||
|
|
||||||
export AMI=`curl -s http://cloud-images.ubuntu.com/locator/ec2/releasesTable | python3 tools/get_ubuntu_ami.py $UBUNTU_CONFIG`
|
|
||||||
|
|
||||||
ec2-create-group -d "mailinabox" "mailinabox"
|
|
||||||
for PORT in 25 53 587 993; do ec2-authorize mailinabox -P tcp -p $PORT -s 0.0.0.0/0; done
|
|
||||||
for PORT in 53; do ec2-authorize mailinabox -P udp -p $PORT -s 0.0.0.0/0; done
|
|
||||||
|
|
||||||
ec2run $AMI -k $EC2_KEYPAIR_NAME -t m1.small -z $AWS_AZ -g mailinabox > instance.info
|
|
||||||
export INSTANCE=`cat instance.info | grep INSTANCE | awk {'print $2'}`
|
|
||||||
|
|
||||||
echo Started instance $INSTANCE
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
while [ 1 ]
|
|
||||||
do
|
|
||||||
export INSTANCE_IP=`ec2-describe-instances $INSTANCE | grep INSTANCE | awk {'print $14'}`
|
|
||||||
if [ -z "$INSTANCE_IP" ]
|
|
||||||
then
|
|
||||||
echo "Waiting for $INSTANCE to start..."
|
|
||||||
else
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 6
|
|
||||||
done
|
|
||||||
|
|
||||||
# Give SSH time to start.
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
echo New instance has IP: $INSTANCE_IP
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import sys, json, re
|
|
||||||
|
|
||||||
# Arguments:
|
|
||||||
region, version, arch, instance_type = sys.argv[1:]
|
|
||||||
|
|
||||||
# Read bytes from stdin.
|
|
||||||
dat = sys.stdin.read()
|
|
||||||
|
|
||||||
# Be flexible. The Ubuntu AMI list is invalid JSON by having a comma
|
|
||||||
# following the last element in a list.
|
|
||||||
dat = re.sub(r",(\s*)\]", r"\1]", dat)
|
|
||||||
|
|
||||||
# Parse JSON.
|
|
||||||
dat = json.loads(dat)
|
|
||||||
|
|
||||||
for item in dat["aaData"]:
|
|
||||||
if item[0] == region and item[2] == version and item[3] == arch and item[4] == instance_type:
|
|
||||||
ami_link = item[6]
|
|
||||||
|
|
||||||
# The field comes in the form of <a href="...">ami-id</a>
|
|
||||||
ami_link = re.sub(r"<.*?>", "", ami_link)
|
|
||||||
|
|
||||||
print(ami_link)
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue