aws-solutions-constructs.aws-cloudfront-apigateway


Nameaws-solutions-constructs.aws-cloudfront-apigateway JSON
Version 2.74.0 PyPI version JSON
download
home_pagehttps://github.com/awslabs/aws-solutions-constructs.git
SummaryCDK Constructs for AWS Cloudfront to AWS API Gateway integration.
upload_time2024-10-22 18:09:09
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aws-cloudfront-apigateway module

<!--BEGIN STABILITY BANNER-->---


![Stability: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)

---
<!--END STABILITY BANNER-->

| **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
|:-------------|:-------------|

<div style="height:8px"></div>

| **Language**     | **Package**        |
|:-------------|-----------------|
|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_cloudfront_apigateway`|
|![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-cloudfront-apigateway`|
|![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.cloudfrontapigateway`|

## Overview

This AWS Solutions Construct implements an AWS CloudFront fronting an Amazon API Gateway REST API.

Here is a minimal deployable pattern definition:

Typescript

```python
import { Construct } from 'constructs';
import { Stack, StackProps } from 'aws-cdk-lib';
import { CloudFrontToApiGateway } from '@aws-solutions-constructs/aws-cloudfront-apigateway';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as api from 'aws-cdk-lib/aws-apigateway';

const lambdaProps: lambda.FunctionProps = {
  code: lambda.Code.fromAsset(`lambda`),
  runtime: lambda.Runtime.NODEJS_16_X,
  handler: 'index.handler'
};

const lambdafunction = new lambda.Function(this, 'LambdaFunction', lambdaProps);

const apiGatewayProps: api.LambdaRestApiProps = {
  handler: lambdafunction,
  endpointConfiguration: {
    types: [api.EndpointType.REGIONAL]
  },
  defaultMethodOptions: {
    authorizationType: api.AuthorizationType.NONE
  }
};

const apiGateway = new api.LambdaRestApi(this, 'LambdaRestApi', apiGatewayProps);

new CloudFrontToApiGateway(this, 'test-cloudfront-apigateway', {
  existingApiGatewayObj: apiGateway
});
```

Python

```python
from aws_solutions_constructs.aws_cloudfront_apigateway import CloudFrontToApiGateway
from aws_cdk import (
    aws_lambda as _lambda,
    aws_apigateway as api,
    Stack
)
from constructs import Construct

lambda_function = _lambda.Function(self, 'LambdaFunction',
                                    code=_lambda.Code.from_asset(
                                        'lambda'),
                                    runtime=_lambda.Runtime.PYTHON_3_9,
                                    handler='index.handler')

api_gateway = api.LambdaRestApi(self, 'LambdaRestApi',
                                handler=lambda_function,
                                endpoint_configuration=api.EndpointConfiguration(
                                    types=[api.EndpointType.REGIONAL]
                                ),
                                default_method_options=api.MethodOptions(
                                    authorization_type=api.AuthorizationType.NONE
                                ))

CloudFrontToApiGateway(self, 'test-cloudfront-apigateway',
                        existing_api_gateway_obj=api_gateway
                        )
```

Java

```java
import software.constructs.Construct;
import java.util.List;

import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.lambda.*;
import software.amazon.awscdk.services.lambda.Runtime;
import software.amazon.awscdk.services.apigateway.*;
import software.amazon.awsconstructs.services.cloudfrontapigateway.*;

final Function lambdaFunction = Function.Builder.create(this, "IndexHandler")
        .runtime(Runtime.NODEJS_16_X)
        .code(Code.fromAsset("lambda"))
        .handler("index.handler")
        .build();

final LambdaRestApi apiGateway = LambdaRestApi.Builder.create(this, "myapi")
        .handler(lambdaFunction)
        .endpointConfiguration(new EndpointConfiguration.Builder()
                .types(List.of(EndpointType.REGIONAL))
                .build())
        .build();

new CloudFrontToApiGateway(this, "test-cloudfront-apigateway", new CloudFrontToApiGatewayProps.Builder()
        .existingApiGatewayObj(apiGateway)
        .build());
```

## Pattern Construct Props

| **Name**     | **Type**        | **Description** |
|:-------------|:----------------|-----------------|
|existingApiGatewayObj|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApi.html)|The regional API Gateway that will be fronted with the CloudFront|
|cloudFrontDistributionProps?|[`cloudfront.DistributionProps \| any`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.DistributionProps.html)|Optional user provided props to override the default props for CloudFront Distribution|
|insertHttpSecurityHeaders?|`boolean`|Optional user provided props to turn on/off the automatic injection of best practice HTTP security headers in all responses from CloudFront|
| responseHeadersPolicyProps?   | [`cloudfront.ResponseHeadersPolicyProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.ResponseHeadersPolicyProps.html) | Optional user provided configuration that cloudfront applies to all http responses.|
|cloudFrontLoggingBucketProps?|[`s3.BucketProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.BucketProps.html)|Optional user provided props to override the default props for the CloudFront Logging Bucket.|

## Pattern Properties

| **Name**     | **Type**        | **Description** |
|:-------------|:----------------|-----------------|
|cloudFrontWebDistribution|[`cloudfront.Distribution`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.Distribution.html)|Returns an instance of cloudfront.Distribution created by the construct|
|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
|cloudFrontFunction?|[`cloudfront.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.Function.html)|Returns an instance of the Cloudfront function created by the pattern.|
|cloudFrontLoggingBucket|[`s3.Bucket`](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-readme.html)|Returns an instance of the logging bucket for CloudFront Distribution.|

## Default settings

Out of the box implementation of the Construct without any override will set the following defaults:

### Amazon CloudFront

* Configure Access logging for CloudFront Distribution
* Enable automatic injection of best practice HTTP security headers in all responses from CloudFront Distribution

### Amazon API Gateway

* User provided API Gateway object is used as-is
* Enable X-Ray Tracing

## Architecture

![Architecture Diagram](architecture.png)

---


© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/awslabs/aws-solutions-constructs.git",
    "name": "aws-solutions-constructs.aws-cloudfront-apigateway",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Amazon Web Services",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/27/08/980c4ddbc7385800eced62549095956bd0a2a6426884e144055115dc534e/aws_solutions_constructs_aws_cloudfront_apigateway-2.74.0.tar.gz",
    "platform": null,
    "description": "# aws-cloudfront-apigateway module\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![Stability: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)\n\n---\n<!--END STABILITY BANNER-->\n\n| **Reference Documentation**:| <span style=\"font-weight: normal\">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|\n|:-------------|:-------------|\n\n<div style=\"height:8px\"></div>\n\n| **Language**     | **Package**        |\n|:-------------|-----------------|\n|![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_cloudfront_apigateway`|\n|![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-cloudfront-apigateway`|\n|![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.cloudfrontapigateway`|\n\n## Overview\n\nThis AWS Solutions Construct implements an AWS CloudFront fronting an Amazon API Gateway REST API.\n\nHere is a minimal deployable pattern definition:\n\nTypescript\n\n```python\nimport { Construct } from 'constructs';\nimport { Stack, StackProps } from 'aws-cdk-lib';\nimport { CloudFrontToApiGateway } from '@aws-solutions-constructs/aws-cloudfront-apigateway';\nimport * as lambda from 'aws-cdk-lib/aws-lambda';\nimport * as api from 'aws-cdk-lib/aws-apigateway';\n\nconst lambdaProps: lambda.FunctionProps = {\n  code: lambda.Code.fromAsset(`lambda`),\n  runtime: lambda.Runtime.NODEJS_16_X,\n  handler: 'index.handler'\n};\n\nconst lambdafunction = new lambda.Function(this, 'LambdaFunction', lambdaProps);\n\nconst apiGatewayProps: api.LambdaRestApiProps = {\n  handler: lambdafunction,\n  endpointConfiguration: {\n    types: [api.EndpointType.REGIONAL]\n  },\n  defaultMethodOptions: {\n    authorizationType: api.AuthorizationType.NONE\n  }\n};\n\nconst apiGateway = new api.LambdaRestApi(this, 'LambdaRestApi', apiGatewayProps);\n\nnew CloudFrontToApiGateway(this, 'test-cloudfront-apigateway', {\n  existingApiGatewayObj: apiGateway\n});\n```\n\nPython\n\n```python\nfrom aws_solutions_constructs.aws_cloudfront_apigateway import CloudFrontToApiGateway\nfrom aws_cdk import (\n    aws_lambda as _lambda,\n    aws_apigateway as api,\n    Stack\n)\nfrom constructs import Construct\n\nlambda_function = _lambda.Function(self, 'LambdaFunction',\n                                    code=_lambda.Code.from_asset(\n                                        'lambda'),\n                                    runtime=_lambda.Runtime.PYTHON_3_9,\n                                    handler='index.handler')\n\napi_gateway = api.LambdaRestApi(self, 'LambdaRestApi',\n                                handler=lambda_function,\n                                endpoint_configuration=api.EndpointConfiguration(\n                                    types=[api.EndpointType.REGIONAL]\n                                ),\n                                default_method_options=api.MethodOptions(\n                                    authorization_type=api.AuthorizationType.NONE\n                                ))\n\nCloudFrontToApiGateway(self, 'test-cloudfront-apigateway',\n                        existing_api_gateway_obj=api_gateway\n                        )\n```\n\nJava\n\n```java\nimport software.constructs.Construct;\nimport java.util.List;\n\nimport software.amazon.awscdk.Stack;\nimport software.amazon.awscdk.StackProps;\nimport software.amazon.awscdk.services.lambda.*;\nimport software.amazon.awscdk.services.lambda.Runtime;\nimport software.amazon.awscdk.services.apigateway.*;\nimport software.amazon.awsconstructs.services.cloudfrontapigateway.*;\n\nfinal Function lambdaFunction = Function.Builder.create(this, \"IndexHandler\")\n        .runtime(Runtime.NODEJS_16_X)\n        .code(Code.fromAsset(\"lambda\"))\n        .handler(\"index.handler\")\n        .build();\n\nfinal LambdaRestApi apiGateway = LambdaRestApi.Builder.create(this, \"myapi\")\n        .handler(lambdaFunction)\n        .endpointConfiguration(new EndpointConfiguration.Builder()\n                .types(List.of(EndpointType.REGIONAL))\n                .build())\n        .build();\n\nnew CloudFrontToApiGateway(this, \"test-cloudfront-apigateway\", new CloudFrontToApiGatewayProps.Builder()\n        .existingApiGatewayObj(apiGateway)\n        .build());\n```\n\n## Pattern Construct Props\n\n| **Name**     | **Type**        | **Description** |\n|:-------------|:----------------|-----------------|\n|existingApiGatewayObj|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApi.html)|The regional API Gateway that will be fronted with the CloudFront|\n|cloudFrontDistributionProps?|[`cloudfront.DistributionProps \\| any`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.DistributionProps.html)|Optional user provided props to override the default props for CloudFront Distribution|\n|insertHttpSecurityHeaders?|`boolean`|Optional user provided props to turn on/off the automatic injection of best practice HTTP security headers in all responses from CloudFront|\n| responseHeadersPolicyProps?   | [`cloudfront.ResponseHeadersPolicyProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.ResponseHeadersPolicyProps.html) | Optional user provided configuration that cloudfront applies to all http responses.|\n|cloudFrontLoggingBucketProps?|[`s3.BucketProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.BucketProps.html)|Optional user provided props to override the default props for the CloudFront Logging Bucket.|\n\n## Pattern Properties\n\n| **Name**     | **Type**        | **Description** |\n|:-------------|:----------------|-----------------|\n|cloudFrontWebDistribution|[`cloudfront.Distribution`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.Distribution.html)|Returns an instance of cloudfront.Distribution created by the construct|\n|apiGateway|[`api.RestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|\n|cloudFrontFunction?|[`cloudfront.Function`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.Function.html)|Returns an instance of the Cloudfront function created by the pattern.|\n|cloudFrontLoggingBucket|[`s3.Bucket`](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-readme.html)|Returns an instance of the logging bucket for CloudFront Distribution.|\n\n## Default settings\n\nOut of the box implementation of the Construct without any override will set the following defaults:\n\n### Amazon CloudFront\n\n* Configure Access logging for CloudFront Distribution\n* Enable automatic injection of best practice HTTP security headers in all responses from CloudFront Distribution\n\n### Amazon API Gateway\n\n* User provided API Gateway object is used as-is\n* Enable X-Ray Tracing\n\n## Architecture\n\n![Architecture Diagram](architecture.png)\n\n---\n\n\n\u00a9 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "CDK Constructs for AWS Cloudfront to AWS API Gateway integration.",
    "version": "2.74.0",
    "project_urls": {
        "Homepage": "https://github.com/awslabs/aws-solutions-constructs.git",
        "Source": "https://github.com/awslabs/aws-solutions-constructs.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28a76d6671c5c9221d87baac036d985d992942d70e46b23124efb1ac326e1bfc",
                "md5": "7312cba4af22787749b6497a295055bd",
                "sha256": "4d00d19f314d07d9aa7c90e49819fdffa134bebe547cbb104dc1424e240ad48e"
            },
            "downloads": -1,
            "filename": "aws_solutions_constructs.aws_cloudfront_apigateway-2.74.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7312cba4af22787749b6497a295055bd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 157260,
            "upload_time": "2024-10-22T18:07:19",
            "upload_time_iso_8601": "2024-10-22T18:07:19.466286Z",
            "url": "https://files.pythonhosted.org/packages/28/a7/6d6671c5c9221d87baac036d985d992942d70e46b23124efb1ac326e1bfc/aws_solutions_constructs.aws_cloudfront_apigateway-2.74.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2708980c4ddbc7385800eced62549095956bd0a2a6426884e144055115dc534e",
                "md5": "35a8a7c5784b89997d823eef0df71ccd",
                "sha256": "b1254a7fdbaafe8a8023a77305af930f997b7999d5695f41d9bb08a5ea6f50b9"
            },
            "downloads": -1,
            "filename": "aws_solutions_constructs_aws_cloudfront_apigateway-2.74.0.tar.gz",
            "has_sig": false,
            "md5_digest": "35a8a7c5784b89997d823eef0df71ccd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 158191,
            "upload_time": "2024-10-22T18:09:09",
            "upload_time_iso_8601": "2024-10-22T18:09:09.781847Z",
            "url": "https://files.pythonhosted.org/packages/27/08/980c4ddbc7385800eced62549095956bd0a2a6426884e144055115dc534e/aws_solutions_constructs_aws_cloudfront_apigateway-2.74.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-22 18:09:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "awslabs",
    "github_project": "aws-solutions-constructs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aws-solutions-constructs.aws-cloudfront-apigateway"
}
        
Elapsed time: 1.31940s