Package: aws-solutions-constructs.aws-cloudfront-apigateway
aws-cloudfront-apigateway module---Reference Documentation:https://docs.aws.amazon.com/solutions/latest/constructs/LanguagePackagePythonaws_solutions_constructs.aws_cloudfront_apigatewayTypescript@aws-solutions-constructs/aws-cloudfront-apigatewayJavasoftware.amazon.awsconstructs.services.cloudfrontapigatewayOverviewThis AWS Solutions Construct implements an AWS CloudFront fronting an Amazon API Gateway REST API.Here is a minimal deployable pattern definition:Typescriptimport{Construct}from'constructs';import{Stack,StackProps}from'aws-cdk-lib';import{CloudFrontToApiGateway}from'@aws-solutions-constructs/aws-cloudfront-apigateway';import*aslambdafrom'aws-cdk-lib/aws-lambda';import*asapifrom'aws-cdk-lib/aws-apigateway';constlambdaProps:lambda.FunctionProps={code:lambda.Code.fromAsset(`lambda`),runtime:lambda.Runtime.NODEJS_16_X,handler:'index.handler'};constlambdafunction=newlambda.Function(this,'LambdaFunction',lambdaProps);constapiGatewayProps:api.LambdaRestApiProps={handler:lambdafunction,endpointConfiguration:{types:[api.EndpointType.REGIONAL]},defaultMethodOptions:{authorizationType:api.AuthorizationType.NONE}};constapiGateway=newapi.LambdaRestApi(this,'LambdaRestApi',apiGatewayProps);newCloudFrontToApiGateway(this,'test-cloudfront-apigateway',{existingApiGatewayObj:apiGateway});Pythonfromaws_solutions_constructs.aws_cloudfront_apigatewayimportCloudFrontToApiGatewayfromaws_cdkimport(aws_lambdaas_lambda,aws_apigatewayasapi,Stack)fromconstructsimportConstructlambda_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)Javaimportsoftware.constructs.Construct;importjava.util.List;importsoftware.amazon.awscdk.Stack;importsoftware.amazon.awscdk.StackProps;importsoftware.amazon.awscdk.services.lambda.*;importsoftware.amazon.awscdk.services.lambda.Runtime;importsoftware.amazon.awscdk.services.apigateway.*;importsoftware.amazon.awsconstructs.services.cloudfrontapigateway.*;finalFunctionlambdaFunction=Function.Builder.create(this,"IndexHandler").runtime(Runtime.NODEJS_16_X).code(Code.fromAsset("lambda")).handler("index.handler").build();finalLambdaRestApiapiGateway=LambdaRestApi.Builder.create(this,"myapi").handler(lambdaFunction).endpointConfiguration(newEndpointConfiguration.Builder().types(List.of(EndpointType.REGIONAL)).build()).build();newCloudFrontToApiGateway(this,"test-cloudfront-apigateway",newCloudFrontToApiGatewayProps.Builder().existingApiGatewayObj(apiGateway).build());Pattern Construct PropsNameTypeDescriptionexistingApiGatewayObjapi.RestApiThe regional API Gateway that will be fronted with the CloudFrontcloudFrontDistributionProps?cloudfront.DistributionProps | anyOptional user provided props to override the default props for CloudFront DistributioninsertHttpSecurityHeaders?booleanOptional user provided props to turn on/off the automatic injection of best practice HTTP security headers in all responses from CloudFrontresponseHeadersPolicyProps?cloudfront.ResponseHeadersPolicyPropsOptional user provided configuration that cloudfront applies to all http responses.cloudFrontLoggingBucketProps?s3.BucketPropsOptional user provided props to override the default props for the CloudFront Logging Bucket.Pattern PropertiesNameTypeDescriptioncloudFrontWebDistributioncloudfront.DistributionReturns an instance of cloudfront.Distribution created by the constructapiGatewayapi.RestApiReturns an instance of the API Gateway REST API created by the pattern.cloudFrontFunction?cloudfront.FunctionReturns an instance of the Cloudfront function created by the pattern.cloudFrontLoggingBuckets3.BucketReturns an instance of the logging bucket for CloudFront Distribution.Default settingsOut of the box implementation of the Construct without any override will set the following defaults:Amazon CloudFrontConfigure Access logging for CloudFront DistributionEnable automatic injection of best practice HTTP security headers in all responses from CloudFront DistributionAmazon API GatewayUser provided API Gateway object is used as-isEnable X-Ray TracingArchitecture© Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.