Flask Elastic Beanstalk Quickstart
Last updated
Last updated
This tutorial will help you deploy a simple flask app that displays a "Welcome to Gallery" splash screen, hosted on Elastic Beanstalk on your own infrastructure. You'll need to have a Gallery account linked with AWS (take a look at the AWS page to do that) and Github to get started.
Go to the templates page on your Gallery dashboard, and click create a template. Name it "Flask Quickstart," and enable the AWS provider.
Now, we'll set up a basic terraform template to use for your infrastructure.
First, fork and clone the starter terraform project. It's important you fork the project to your own Github namespace in order to be able to add it to the template later in the tutorial.
2. Add the following to the vars.tf
file.
This defines the Gallery variables, which allows our build system to inject variables to your infrastructure-as-code projects at build time. In this case, we're going to use the var.gallery_info.env_name
variable, which is a unique identifier for each environment.
3. Now, add the following code to the eb.tf
file.
This snippet defines a basic elastic beanstalk environment and application, with the name of the environment and application including the gallery environment name (in order to have uniqueness in those fields).
4. Add the following to outputs.tf
. Gallery can use outputs to give you access to data in the application build step.
5. Push the changes to your repository fork.
Now, we'll set up the flask application repository to deploy on your newly created infrastructure.
First, fork the sample repository into your Github account/organization, and clone the repository.
2. Add the following into the .gallery-deploy.yml
file.
This deploy file has a single job and stage that deploys the application to the elastic beanstalk environment we created in the previous step.
Now, head back to the Gallery template creation flow, and click "Add Service" and "From Terraform Snippet.
2. Select the "Repository" terraform type, link your forked terraform repository, and click "Save."
3. Once the new template is created, go to the URL Mappings tab, select the base_url terraform output, leaving the subdomain blank and hit "Save." This will allow Gallery to serve traffic to the newly created environment.
4. Click next, and click "Add Repo" on the deployment commands page. Then, select the forked application repository, and the "Defined in Repo" build type, and click save.
5. Click next and finish the template creation process.
Go to the "Environments" tab, and click "Add Environment."
Pick an environment name, select the template you created in the previous step, and click "Save"
Wait for the environment status to change to active and refresh the page -- you should see a link to your new environment!