{"id":18485907,"url":"https://github.com/biomapas/b.cfnapiv2","last_synced_at":"2026-01-30T11:26:07.015Z","repository":{"id":57414296,"uuid":"410233217","full_name":"Biomapas/B.CfnApiV2","owner":"Biomapas","description":"All the nice features for ApiGatewayV2 that are missing from ApiGatewayV1. Ease to enable staging, caching \u0026 various authorization.","archived":false,"fork":false,"pushed_at":"2023-08-04T08:00:11.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-08T14:49:55.727Z","etag":null,"topics":["amazon-web-services","api","api-gateway","api-gateway-v2","aws","aws-cdk","aws-cdk-python","aws-lambda","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Biomapas.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-25T09:43:08.000Z","updated_at":"2022-02-17T07:03:17.000Z","dependencies_parsed_at":"2022-08-26T20:13:19.050Z","dependency_job_id":null,"html_url":"https://github.com/Biomapas/B.CfnApiV2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnApiV2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnApiV2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnApiV2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biomapas%2FB.CfnApiV2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Biomapas","download_url":"https://codeload.github.com/Biomapas/B.CfnApiV2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223343101,"owners_count":17129944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-web-services","api","api-gateway","api-gateway-v2","aws","aws-cdk","aws-cdk-python","aws-lambda","python","python3"],"created_at":"2024-11-06T12:47:06.142Z","updated_at":"2026-01-30T11:26:06.981Z","avatar_url":"https://github.com/Biomapas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# B.CfnApiV2\n\n![Pipeline](https://github.com/Biomapas/B.CfnApiV2/workflows/Pipeline/badge.svg?branch=master)\n\nAn API Gateway resource that adds convenient functionality over traditional `CfnApi` resource. \nIt lets you easily enable authorization, stages, and CDNs. \n\n### Description\n\nEssentially this resource is a wrapper resource for `aws_apigatewayv2` module's `CfnApi`. Meaning, \nthat you can easily swap `CfnApi` and this `Api` resource with no major impact. But why would you \nwant to switch a traditional `CfnApi` to this one. Mainly these convenient features:\n- Easy to add `CloudFront` distribution on top of the API (enabling CDN).\n- Easy to enable `Stage` and attached to the api.\n- Easy to add authorization with `UserPoolAuthorizer` \u0026 `ApiKeyAuthorizer`.\n\n### Remarks\n\n[Biomapas](https://www.biomapas.com/) aims to modernise life-science industry by sharing its IT knowledge with other companies and the community. \nThis is an open source library intended to be used by anyone. \nImprovements and pull requests are welcome. \n\n### Related technology\n\n- Python3\n- AWS CDK\n- AWS Lambda\n- AWS API Gateway\n- AWS CloudFront\n- AWS User Pool authorization\n\n### Assumptions\n\nThis project assumes you know what Lambda functions are and how code is being shared between them\n(Lambda layers). \n\n- Excellent knowledge in IaaC (Infrastructure as a Code) principles.\n- Excellent knowledge in Lambda functions and API Gateway service.  \n- Good experience in AWS CDK and AWS CloudFormation.\n\n### Useful sources\n\n- AWS CDK:\u003cbr\u003ehttps://docs.aws.amazon.com/cdk/api/latest/docs/aws-construct-library.html\n- AWS CloudFormation:\u003cbr\u003ehttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html\n- AWS API Gateway:\u003cbr\u003ehttps://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html\n- AWS API Gateway V2:\u003cbr\u003ehttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-api.html\n- Custom User Pool Authorizer:\u003cbr\u003ehttps://github.com/Biomapas/B.CfnCustomUserPoolAuthorizer\n- Custom api key authorizer:\u003cbr\u003ehttps://github.com/Biomapas/B.CfnCustomApiKeyAuthorizer\n- Custom user pool authorizer:\u003cbr\u003ehttps://github.com/Biomapas/B.CfnCustomUserPoolAuthorizer\n\n### Install\n\nBefore installing this library, ensure you have these tools setup:\n\n- Python / Pip\n- AWS CDK\n\nTo install this project from source run:\n\n```\npip install .\n```\n\n\nOr you can install it from a PyPi repository:\n\n```\npip install b-cfn-api-v2\n```\n\n\n### Usage \u0026 Examples\n\nThe traditional way of creating an API looks something like this:\n\n```python\nfrom aws_cdk.aws_apigatewayv2 import CfnApi\n\nCfnApi(\n    scope=Stack(),\n    id='Api',\n    name='Api',\n    description='Sample description.',\n    protocol_type='HTTP',\n    cors_configuration=CfnApi.CorsProperty(\n        allow_methods=['GET', 'PUT', 'POST', 'OPTIONS', 'DELETE'],\n        allow_origins=['*'],\n        allow_headers=[\n            'Content-Type',\n            'Authorization'\n        ],\n        max_age=300\n    )\n)\n```\n\nTo create our resource `Api` is exactly the same:\u003cbr\u003e\n(It works since `Api` is a pure wrapper of `CfnApi` resource.)\n\n```python\nfrom b_cfn_api_v2.api import Api\n\nApi(\n    scope=Stack(),\n    id='Api',\n    name='Api',\n    description='Sample description.',\n    protocol_type='HTTP',\n    cors_configuration=Api.CorsProperty(\n        allow_methods=['GET', 'PUT', 'POST', 'OPTIONS', 'DELETE'],\n        allow_origins=['*'],\n        allow_headers=[\n            'Content-Type',\n            'Authorization'\n        ],\n        max_age=300\n    )\n)\n```\n\nThree main advantages of this `Api` resource:\n\n- **Easy to enable default stage.**\n\n```python\nfrom b_cfn_api_v2.api import Api\n\napi = Api(...)\napi.enable_default_stage('dev')\n```\n\n- **Easy to enable authorization.**\n\n```python\nfrom b_cfn_api_v2.api import Api\nfrom b_cfn_custom_userpool_authorizer.config.user_pool_config import UserPoolConfig\n\napi = Api(...)\n\n# Your authorized endpoint will require `Authorization`\n# supplied in headers.\n# Read more:\n# https://github.com/Biomapas/B.CfnCustomUserPoolAuthorizer\napi.enable_user_pool_authorizer(UserPoolConfig(\n    user_pool_id='id',\n    user_pool_region='region',\n    user_pool_client_id='client'\n))\n\n# Your authorized endpoint will require `ApiKey` and `ApiSecret`\n# supplied in headers.\n# Read more:\n# https://github.com/Biomapas/B.CfnCustomApiKeyAuthorizer\napi.enable_api_key_authorizer()\n```\n\n- **Easy to enable CDN.**\n\n```python\nfrom b_cfn_api_v2.api import Api\nfrom aws_cdk.aws_cloudfront import CachePolicy\n\napi = Api(...)\napi.enable_cdn(default_behavior_cache_policy=CachePolicy.CACHING_OPTIMIZED)\n```\n\n### Testing\n\nThis package has integration tests based on **pytest**.\nTo run tests simply run:\n\n```\npytest b_cfn_api_v2_test/integration/tests\n```\n\n### Contribution\n\nFound a bug? Want to add or suggest a new feature? \nContributions of any kind are gladly welcome. \nYou may contact us directly, create a pull-request or an issue in github platform. \nLets modernize the world together.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiomapas%2Fb.cfnapiv2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiomapas%2Fb.cfnapiv2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiomapas%2Fb.cfnapiv2/lists"}