Skip to content

This project is part of the University of Surrey's Master's degree course in Cloud Computing. It demonstrates how to deploy a Flask web application on various cloud platforms, including AWS Lambda, AWS EC2, and Google Cloud Platform (GCP). The repository includes configuration files and setup guides for seamless deployment across these services

License

Notifications You must be signed in to change notification settings

BharadwajMahanthi/Cloud-Computing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloud Computing

To make sure your Flask application works on AWS Lambda, EC2, and GCP, you need to package it appropriately and handle deployment specifics for each platform. Here's a general guide for each environment:

AWS Lambda

For AWS Lambda, you can use the Serverless Framework or Zappa to deploy Flask applications.

  1. Install Zappa:

    pip install zappa
  2. Initialize Zappa:

    zappa init
  3. Configure Zappa: Ensure your zappa_settings.json is correctly configured. Here's a basic example:

    {
      "dev": {
        "app_function": "app.app",  # The entry point to your application
        "aws_region": "us-east-1",  # Your AWS region
        "s3_bucket": "your-s3-bucket"  # S3 bucket for deployment
      }
    }
  4. Deploy with Zappa:

    zappa deploy dev

AWS EC2

For AWS EC2, you can set up a virtual machine, install necessary dependencies, and run your Flask application.

  1. Launch an EC2 instance:

    • Choose an appropriate instance type and AMI (e.g., Ubuntu).
  2. Connect to your instance:

    ssh -i /path/to/your-key.pem ubuntu@your-ec2-public-dns
  3. Install dependencies:

    sudo apt update
    sudo apt install python3-pip python3-dev nginx
    sudo pip3 install virtualenv
  4. Clone your project and set up the environment:

    git clone https://github.com/BharadwajMahanthi/Cloud-Computing.git
    cd your-project
    virtualenv venv
    source venv/bin/activate
    pip install -r requirements.txt
  5. Run your application:

    flask run --host=0.0.0.0
  6. Configure Nginx:

    • Create a new Nginx configuration file:
      sudo nano /etc/nginx/sites-available/your-project
    • Add the following content:
      server {
          listen 80;
          server_name your-ec2-public-dns;
      
          location / {
              proxy_pass http://127.0.0.1:5000;
              proxy_set_header Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Forwarded-Proto $scheme;
          }
      }
    • Enable the configuration:
      sudo ln -s /etc/nginx/sites-available/your-project /etc/nginx/sites-enabled
      sudo nginx -t
      sudo systemctl restart nginx

Google Cloud Platform (GCP)

For GCP, you can deploy your Flask application using Google App Engine or a VM instance.

Google App Engine

  1. Create a app.yaml file:

    runtime: python39
    
    handlers:
    - url: /
      script: auto
  2. Deploy to App Engine:

    gcloud app deploy

Google Compute Engine (VM Instance)

  1. Create a VM instance on GCP and SSH into it.

  2. Install dependencies (similar to EC2):

    sudo apt update
    sudo apt install python3-pip python3-dev nginx
    sudo pip3 install virtualenv
  3. Clone your project and set up the environment:

    git clone https://github.com/your-repo/your-project.git
    cd your-project
    virtualenv venv
    source venv/bin/activate
    pip install -r requirements.txt
  4. Run your application:

    flask run --host=0.0.0.0
  5. Configure Nginx (similar to EC2).

Flask Application Code

Make sure your Flask application code is ready for deployment.

About

This project is part of the University of Surrey's Master's degree course in Cloud Computing. It demonstrates how to deploy a Flask web application on various cloud platforms, including AWS Lambda, AWS EC2, and Google Cloud Platform (GCP). The repository includes configuration files and setup guides for seamless deployment across these services

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages