Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

AWS Developer Notes

malachig edited this page Sep 12, 2014 · 7 revisions

How to make the changes needed for the SGMS install persistent when starting from a community AMI ?

One of the important things that needs to be done before the SGMS can be installed is to configure /opt . This is the directory where a lot of the data/code from the installation goes, thus we need to make sure that we have sufficient storage here. To do this, we need to mount the allocated drives(for example: 'xvdb' to /opt). This has to be persistent so that every instance of the AMI has this pre-configured. We decided to do this using the cloudconfig mount settings, to change the cloudconfig settings, we edited the 'cc_mounts.py' file - sudo vim /usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_mounts.py Scroll down to the method 'handle' and change the value "/mnt" in the defmnts variable to "/opt". This will ensure the mount to "/opt"

Before saving an image of this instance, make sure you unmount /mnt and also replace the last line in the "/etc/fstab" file with /dev/xvdb /opt auto defaults,nobootwait,comment=cloudconfig 0 2 to make sure that "mnt" is not mounted on the next instance.

Cloud-Init provides a convenient way to run scripts each time an instance is made, each time an instance is booted etc. More details can be found on their website here

For our purposes we'd like to make a series of steps automated before the sgms install, these steps are

cd /opt; mkdir src; cd src
sudo chown -R ubuntu:ubuntu /opt

To run these only when an instance is created we make this into a bash script say sgms_preinstall.sh. This script needs to be made an executable(by running chmod +x). We then copy this script over to /var/lib/cloud/scripts/per-instance/sgms_preinstall.sh Note the location here per-instance, there are other folders in the same location such as per-boot etc which can be used for other purposes. Hopefully this gives an example of how CloudInit can be used to automate the configuration of the system prior to installation.

Finally, save the instance as a new AMI by right clicking the instance and clicking on "Save Image".

Change the permissions of the AMI to "public" if you would like it to be listed under the Community AMI's.

Testing of the GMS on Amazon AWS EC2 and development of this documentation was generously supported by Amazon AWS Education grants.

Clone this wiki locally