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.
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.
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.
Clone this repository to your local machine using:
git clone https://github.com/zennur/AWS-CDK-Import-OpenAPI.gitNavigate into the repository directory:
cd aws-cdk-openapi-importerInstall required dependencies:
pip install -r requirements.txtPrepare 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 deploycreate_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.
Contributions are welcome! Feel free to fork the repository and submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.