Deploying your application to EC2 during stack creation
In this section, we will get hands-on experience with cfn-init
by using it to bootstrap an application on EC2 instances.
We will begin with a simple “Hello, World!” example.
Creating a “Hello, World!” application
We’ll start by implementing a basic “Hello, World!” application, which is going to be deployed in an AutoScaling
group. This is going to be an application based on Flask—a lightweight Python web framework:
- Let’s develop our app:
// hello-world-flask.py#!/usr/bin/env python3from flask import Flaskapp = Flask(__name__)@app.route("/")def hello(): return «Hello, World, from AWS!"if __name__ == "__main__": app.run(host="0.0.0.0", port=80)
Nothing really serious. We will store this application on S3 and use
cfn-init
to install Python and Flask, pull the code from...