Craig T.'s picture

Hey guys. I have a custom appliance built off of base. It is basically installing docker, docker-compose, and a python package that is needed to run our application for those that don't want to get it running in Docker/Kubernetes themselves. It works great to create an ISO, where I do a bunch of stuff at firstboot, including setting several random keys, SSL certs, etc. I need to get this running on an EC2 server for a customer. Is there any way to export to AMI, so they still get all the firstboot stuff? The only thing I am seeing online is basically spin it up in VMware, export to OVA, then convert to AMI, but this means all the firstboot stuff will already be done. Any help would be appreciated!

 

Thanks

Craig T.

Forum: 
Tags: 
Jeremy Davis's picture

Hi Craig

Have a look at buildtasks. Specifically bt-ec2. It's what we use internally to build our Hub AMIs (and AWS Marketplace) from an ISO.

Sorry there aren't any docs, we primarily publish it for transparency - but it should be workable for your use case. There are a lot of bits that you technically don't need and possibly won't want, but you'll either need to create them (e.g. hash file, TKLBAM profile, etc) or tweak the script(s) to skip them. Hopefully you know a bit of bash and have some vague experience with git? (I'm guessing so).

FWIW I have a pre-configured server for our builds so my recollection may be a bit rusty and I may overlook something. Apologies in advance if it doesn't "just work".

You'll want to run it on an existing TurnKey EC2 instance. We run a EC2 instance of TKLDev, but at least in theory in should work on any TKL appliance.

The process should go something like this:

On your TurnKey EC2 instance, clone buildtasks (we clone it to /turnkey/fab/buildtasks - but shouldn't matter). Copy the aws.cfg and common.cfg as appropriate. Upload your iso (to $BT_ISOS directory) and name it using the TKL naming convention (i.e. turnkey-APP_NAME-TKL_VERSION-DEBIAN_CODENAME-ARCH.iso - e.g. turnkey-custom-app-18.0-bookworm-amd64.iso. If you want to build a hash file, run:

./bin/generate-signature path/to/iso

(If you don't, tweak the script to skip that step).

If you want to build a TKLBAM profile, clone the tklbam-profiles repo and create a profile file named 'APP_NAME' (i.e. name of your app, e.g. custom-app) and then run:

./bin/generate-tklbam-profile custom-app

(If you don't again comment out the relevant code).

Once everything is set up, to actually build the AMI (assuming you name it 'custom-app'), run:

./bt-ec2 turnkey-custom-app-18.0-bookworm-amd64.iso

Good luck. :)

Add new comment