Skip to content

Releases: aws-samples/eb-python-flask

Environment Variables for Feature Flags and Flask Debugging

12 Jul 14:46
Compare
Choose a tag to compare

This release illustrates the use of environment variables to control feature flags and Flask debugging, leveraging Elastic Beanstalk configuration files to set the env vars on the application servers.

Use the New Features

Modify your application's Software Configuration (see Changing Software Configuration for detailed instructions) to first disable FLASK_DEBUG. Then, enable the cool new feature via a feature-flag by setting ENABLE_COOL_NEW_FEATURE to true.

About the New Features

We modify .ebextensions/python.config (from the previous release) and specify 3 new environment variables: FLASK_DEBUG, APP_VERSION, and ENABLE_COOL_NEW_FEATURE:

option_settings:
  - namespace: aws:elasticbeanstalk:container:python:staticfiles
    option_name: /static/
    value: static/
  - option_name: FLASK_DEBUG
    value: true
  - option_name: APP_VERSION
    value: v1.2.0
  - option_name: ENABLE_COOL_NEW_FEATURE
    value: false

Elastic Beanstalk makes these variables available to our application via the environment. We can access them in our app and, for example, decide if a new feature should be visible or not (i.e., a feature flag!):

# Get cool new feature flag from env
enable_cool_new_feature = os.environ.get('ENABLE_COOL_NEW_FEATURE') in ['true', 'True']

The ZIP file attached to this release can be deployed directly to AWS Elastic Beanstalk.

Python and Flask with Jinja2 Templates and Elastic Beanstalk Customization

12 Jul 14:35
Compare
Choose a tag to compare

Extending the sample in the AWS Elastic Beanstalk Developer Guide, this release adds Jinja2 templates and static files, as well as Elastic Beanstalk container customization via the .ebextensions directory.

Elastic Beanstalk configuration files (discussed in the documentation allow an Elastic Beanstalk application to be customized via code. In this release, we create a .ebextensions/python.config in our application and specify a setting that will allow our app to serve static assets:

option_settings:
  - namespace: aws:elasticbeanstalk:container:python:staticfiles
    option_name: /static/
    value: static/

The ZIP file attached to this release can be deployed directly to AWS Elastic Beanstalk.

Hello, World! with Flask

12 Jul 04:44
Compare
Choose a tag to compare

Minimal "Hello, world!" page at / from the AWS Elastic Beanstalk Developer Guide.


The ZIP file attached to this release can be deployed directly to AWS Elastic Beanstalk.