Skip to content

First Elastic Beanstalk Deploy for Python

This tutorial explains the first deployment workflow for a Python Flask app on AWS Elastic Beanstalk. It follows the EB CLI sequence documented in AWS getting started guidance.

Prerequisites

  • Completed local app setup from 01-local-run.md.
  • AWS CLI and EB CLI installed.
  • An initialized AWS profile (aws configure) with masked account context.
  • Source project includes application.py, requirements.txt, and optional Procfile.

What You'll Build

You will create:

  • An Elastic Beanstalk application definition.
  • A web server environment for Python.
  • An application version deployed from your source bundle.
  • A baseline health and status check routine.

Steps

  1. Initialize EB metadata in your project.
eb init --platform "Python 3.11 running on 64bit Amazon Linux 2023" --region "$REGION"
  1. Create an environment (example names only).
export APP_NAME="eb-python-guide"
export ENV_NAME="eb-python-guide-dev"
export REGION="ap-northeast-2"
eb create "$ENV_NAME" --single
  1. Deploy current source as a new application version.
eb deploy "$ENV_NAME" --staged
  1. Check environment status and health.
eb status "$ENV_NAME"
eb health "$ENV_NAME"
  1. Open environment endpoint.
eb open "$ENV_NAME"

Source bundle expectations from AWS docs:

  • Application source files are packaged as an application version.
  • .elasticbeanstalk/ stores CLI project configuration.
  • .ebextensions/ and .platform/ are included when present.
flowchart LR
    A[Local Project] --> B[eb init]
    B --> C[eb create]
    C --> D[Environment Resources]
    D --> E[eb deploy]
    E --> F[Application Version Deployed]
    F --> G[eb status and eb health]

Verification

Validate deployment without assuming production traffic:

eb status "$ENV_NAME"
eb events "$ENV_NAME" --follow
aws elasticbeanstalk describe-environments --application-name "$APP_NAME" --region "$REGION"

Expected checks:

  • Environment shows Ready and health Green after successful deploy.
  • Event stream shows successful application version deployment.
  • Environment URL returns your Flask response.

If health is not green, inspect logs in the next tutorial.

See Also

Sources