Skip to content

Seamlessly use OpenAPI spec to generate all the API Gateway resources in AWS CDK

License

Notifications You must be signed in to change notification settings

zennur/AWS-CDK-Import-OpenAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS CDK Import OpenAPI

Seamlessly use OpenAPI spec to generate all the API Gateway resources in AWS CDK

This repository contains a Python module that automates the creation of AWS infrastructure using the AWS Cloud Development Kit (CDK). It dynamically generates AWS Lambda functions and an API Gateway based on an OpenAPI specification file. This tool is designed to help developers quickly deploy serverless architectures that are defined by OpenAPI specs.

Features

Automatic Lambda Function Creation: Generates AWS Lambda functions for each endpoint defined in the OpenAPI specification.

API Gateway Integration: Sets up an API Gateway that routes requests to the corresponding Lambda functions.

Flexible Deployment: Integrates with AWS IAM, S3, Cognito, CloudFront, and other AWS services to provide a comprehensive and secure environment.

Customizable: Allows for custom configurations of Lambda functions and API Gateway settings.

Prerequisites

To use this module, you will need:

AWS CLI installed and configured with appropriate permissions. Python 3.8 or higher. AWS CDK installed. An OpenAPI specification file in YAML format.

Installation

Clone this repository to your local machine using:

git clone https://github.com/zennur/AWS-CDK-Import-OpenAPI.git

Navigate into the repository directory:

cd aws-cdk-openapi-importer

Install required dependencies:

pip install -r requirements.txt

Usage

Prepare Your OpenAPI Specification: Ensure your OpenAPI YAML file is ready and located within your project directory.

Configure the CDK Stack: Modify the API class within the api.py file to customize the AWS environment according to your needs.

Deploy: Run the following commands to deploy your infrastructure to AWS:

cdk bootstrap
cdk deploy

API Class Reference

create_lambda_function: Creates a Lambda function based on parameters such as function name, Lambda layer, IAM role, and environment variables.

create_api_gateway: Sets up the API Gateway resources and methods defined in your OpenAPI specification file.

get_or_create_resource: Helper function to create or retrieve API Gateway resources.

get_or_create_lambda: Helper function to create or retrieve Lambda functions if they don't already exist.

Contributing

Contributions are welcome! Feel free to fork the repository and submit pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Seamlessly use OpenAPI spec to generate all the API Gateway resources in AWS CDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages