Migration from shared hosting to amazon web services

I was keen to implement my website in python (using flask) but my shared host didn't host python websites. Since amazon web services (aws) has a years free hosting I thought I'd give implementing the website the go while migrating to aws.

Here's some things that were far more work than they should be:

  1. Amazon doesn't have an easy way to force https only. To achieve this it appears to be necessary to alter the configuration for the server itself. I actually gave up on this as it was substantially easier to force https on the specific pages I needed than get http to redirect to https.

  2. This problem came about because url_for() seems to always return http. There are some ways to fix this but the suggested solutions didn't work for me. In the end I just added the _external and _scheme variables to all url_for calls. A pain, but it's not much code and the website won't be changing much.

  3. This led to a further issue: getting flask to host https locally. The necessary documentation is a little buried, but well explained else where. I ended up making the code for this dependent on my config debug setting.

    if (application.config['DEBUG']):                                                
        context = ('../openssl/server.crt', '../openssl/privatekey.pem')             
        application.run('', port=8100, ssl_context=context)
  4. I use a variety of python modules one of which uses libffi. Apparently getting libffi installed on an instance is simple. Of course the answer didn't work for me... and I have yet to figure out why. What I ended up using is

        command: yum install libffi-devel