Skip to main content

Build and deploy AWS API Gateways using AWS Lambda

Project description

###Requirements

  • Python 3.6
  • Pip

Install Dependencies

  • pipenv
pip install pipenv
  • awscli
pip install awscli

Install aws-lambda-api-builder

Install from pip:

pip install aws-lambda-api-builder

Install from Github

git clone https://github.com/zmiler91/aws-lambda-api-builder
cd aws-lambda-api-builder
pipenv install
python setup.py sdist bdist_wheel
pipenv install -e .

If you've installed aws-lambda-api-builder from Github then you will need to use pipenv shell in order for your zlab to be recognized.

pipenv shell
zlab --help

> usage: api_builder [sub-command] [options]
> 
> This is a CLI to build, package, and release AWS APIs using API Gateway and
> Lambda.
> 
> positional arguments:
>  {lambda}
> 
> optional arguments:
>   -h, --help

Setup

Since aws-lambda-api builder uses boto3 to interact with AWS, you will need to install and configure the AWS CLI. If you have not already installed the AWS CLI, please refer to the "Install Dependencies" section of this README.

Creating an S3 bucket

aws-lambda-api-builder will upload a zipped archive of your application to S3 so it can be used in your Lambda functions. You can use the AWS console to create an S3 bucket; for the purposes of this README I've created a bucket called my-example-api.

Creating an IAM Policy

We will be creating an IAM User for aws-lambda-api-builder in the next section, but before we do so we will need to create an IAM Policy so we can limit the user's permissions and only allow them to read out of the bucket created in the previous section.

You can create this policy using the Visual Editor or you can copy the JSON document below replacing my-example-api with the name of your S3 bucket:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "s3:PutObject",
            "Resource": [
                "arn:aws:s3:::my-example-api/*"
            ]
        }
    ]
}

Once you've defined your policy you will need to give your policy a name, for the purposes of this README I've name my policy aws-lambda-api-builder-s3. You can also give your policy an optional description. If you want to grant access to multiple buckets, then you just need to add the bucket to the Resource array in the policy document.

Creating an IAM User

aws-lambda-api-builder needs access to some resources in your AWS account so it can upload S3 files that contain your zipped archive. To do this, you'll want to create an IAM user in the AWS console.

User name: aws-api-lambda-builder
Access type: Programmatic access

After you've defined the name and access type, you will be asked to set a permission. You can use the "Attach existing policies directly" option and find and select the policy created in the previous section.

Once the user has been created you will be provided an "Access key ID" and a "Secret access key", you will want to remember both of these. Your credentials will only be provided to you once, so you will not be able to recover them if you do not write them down.

Configure AWS

Once you've created your IAM user you will need to configure the AWS CLI.

aws configure
> AWS Access Key ID [None]: {access key from the previous section}
> AWS Secret Access Key [None]: {secret access key from the previous section}
> Default region name [None]: {the aws region you're using, mine is us-east-1}
> Default output format [None]:

Your configuration and access keys will be saved to the .aws directory in your home directory. If you've already configured your AWS CLI with another user, then you can attach the IAM Policy created in the previous section to this user.

Development Environment

Integrate the pipenv environment by following the instructions here: https://www.jetbrains.com/help/pycharm/pipenv.html

Usage Examples

$ zlab lambda --help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-lambda-api-builder-0.0.8.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

aws_lambda_api_builder-0.0.8-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file aws-lambda-api-builder-0.0.8.tar.gz.

File metadata

  • Download URL: aws-lambda-api-builder-0.0.8.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for aws-lambda-api-builder-0.0.8.tar.gz
Algorithm Hash digest
SHA256 c5f274daf1dd91bdeb99c5ed831c3ed6502fb958345334ca043655ee8276c153
MD5 fdb26ad55cd3b5ef87e5d144fba2d403
BLAKE2b-256 9e14a0f9393b59dee2e2bf1914403ea7afc63747284b94d50b61a443dfbe8ff1

See more details on using hashes here.

File details

Details for the file aws_lambda_api_builder-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: aws_lambda_api_builder-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for aws_lambda_api_builder-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 797eafb210677e3cafbba5772a44df2d0b087642b9e67d3b618f117055ebee86
MD5 b17b1d14a8d151284918998a36fb0d12
BLAKE2b-256 bc5f7f0bd6773923e07483dd94b5907842fa56d577b59c2fa3eed6cc2af24ac4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page