mununki / RateLink-Lambda-Zappa

Serverless GraphQL API powered by Zappa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Severless GraphQL API with Django and Graphene

Setup Guide

  1. Virtualenv with Python 3.6

    $ python3.6 -m venv env_django-lambda
    $ source env_django-lambda/bin/activate
    

    Zappa currently supports only Python 3.6

  2. Install requirements.txt

    $ pip3 install -r requirements.txt
    
  3. Set up RDS in my_django_proejct/settings.py (using already existing RDS instance)

    postgreSQL

    DATABASES = {
      'default': {
      'ENGINE': 'django.db.backends.postgresql_psycopg2',
      'NAME': 'db_name',
      'USER': 'user_name',
      'PASSWORD': 'rds_master_password',
      'HOST': 'something.rds.amazonaws.com',
      'PORT': '5432',
      }
    }
  4. Valid AWS account and Create IAM user with role for zappa

  • Create IAM user for lambda
    • Permissions policies
      • AWSLambdaFullAccess
      • IAMFullAccess
      • AmazonAPIGatewayAdministrator
      • AWSCloudFormationReadOnlyAccess
      • Creating custom policy for only zappa
      {
        "Version": "2018-10-18",
        "Statement": [
          {
            "Sid": "my_project_zappa_1",
            "Effect": "Allow",
            "Action": [
              "cloudformation:CreateStack",
              "cloudformation:CreateChangeSet",
              "cloudformation:ListStacks",
              "cloudformation:UpdateStack",
              "cloudformation:DescribeStacks",
              "cloudformation:DescribeStackResource",
              "cloudformation:DescribeStackEvents",
              "cloudformation:ValidateTemplate",
              "cloudformation:DescribeChangeSet",
              "cloudformation:ExecuteChangeSet"
            ],
            "Resource": [
              "*"
            ]
          }
        ]
      }
      
  1. Initializing Zappa

    $ zappa init
    
  2. Edit zappa_settings.json

    • add VPC config with subnet1, subnet2, securityGroupId of AWS
  3. Deployment

    $ zappa deploy dev
    

About

Serverless GraphQL API powered by Zappa