[![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)
# @cloudcomponents/cdk-lambda-at-edge-pattern
[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)
[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)
[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-lambda-at-edge-pattern)
[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-lambda-at-edge-pattern/)
> CDK Constructs for Lambda@Edge pattern: HttpHeaders
## Install
TypeScript/JavaScript:
```bash
npm i @cloudcomponents/cdk-lambda-at-edge-pattern
```
Python:
```bash
pip install cloudcomponents.cdk-lambda-at-edge-pattern
```
## How to use
```python
import { StaticWebsite } from '@cloudcomponents/cdk-static-website';
import { OriginMutation } from '@cloudcomponents/cdk-lambda-at-edge-pattern';
import { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';
import { Construct } from 'constructs';
export class StaticWebsiteStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {
domainName: 'cloudcomponents.org',
});
// Create a lambda at edge
const originMutation = new OriginMutation(stack, 'OriginMutation');
new StaticWebsite(this, 'StaticWebsite', {
hostedZone,
domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],
edgeLambdas: [originMutation],
removalPolicy: RemovalPolicy.DESTROY,
});
}
}
```
### Cloudfront Distribution
```python
new cloudfront.Distribution(this, 'myDist', {
defaultBehavior: {
origin: new origins.S3Origin(myBucket),
edgeLambdas: [httpHeaders],
},
});
```
### HttpHeaders
```python
const httpHeaders = new HttpHeaders(this, 'HttpHeaders', {
httpHeaders: {
'Content-Security-Policy':
"default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; object-src 'none'; connect-src 'self'",
'Strict-Transport-Security':
'max-age=31536000; includeSubdomains; preload',
'Referrer-Policy': 'same-origin',
'X-XSS-Protection': '1; mode=block',
'X-Frame-Options': 'DENY',
'X-Content-Type-Options': 'nosniff',
'Cache-Control': 'no-cache',
},
});
```
### OriginMutation
https://chrisschuld.com/2020/05/gatsby-hosting-on-cloudfront/
```python
const originMutation = new OriginMutation(stack, 'OriginMutation');
```
## API Reference
See [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-lambda-at-edge-pattern/API.md).
## Example
See more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).
## License
[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-lambda-at-edge-pattern/LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/cloudcomponents/cdk-constructs",
"name": "cloudcomponents.cdk-lambda-at-edge-pattern",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.8",
"maintainer_email": null,
"keywords": null,
"author": "hupe1980",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/b7/5c/5dd05d2a5d28af52bc0a0aec2c359629d6a884babbc54304ea3e28bf157a/cloudcomponents.cdk-lambda-at-edge-pattern-2.3.0.tar.gz",
"platform": null,
"description": "[![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)\n\n# @cloudcomponents/cdk-lambda-at-edge-pattern\n\n[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)\n[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)\n[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-lambda-at-edge-pattern)\n[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-lambda-at-edge-pattern/)\n\n> CDK Constructs for Lambda@Edge pattern: HttpHeaders\n\n## Install\n\nTypeScript/JavaScript:\n\n```bash\nnpm i @cloudcomponents/cdk-lambda-at-edge-pattern\n```\n\nPython:\n\n```bash\npip install cloudcomponents.cdk-lambda-at-edge-pattern\n```\n\n## How to use\n\n```python\nimport { StaticWebsite } from '@cloudcomponents/cdk-static-website';\nimport { OriginMutation } from '@cloudcomponents/cdk-lambda-at-edge-pattern';\nimport { RemovalPolicy, Stack, StackProps, aws_route53 } from 'aws-cdk-lib';\n\nimport { Construct } from 'constructs';\n\nexport class StaticWebsiteStack extends Stack {\n constructor(scope: Construct, id: string, props: StackProps) {\n super(scope, id, props);\n\n const hostedZone = aws_route53.HostedZone.fromLookup(this, 'HostedZone', {\n domainName: 'cloudcomponents.org',\n });\n\n // Create a lambda at edge\n const originMutation = new OriginMutation(stack, 'OriginMutation');\n\n new StaticWebsite(this, 'StaticWebsite', {\n hostedZone,\n domainNames: ['cloudcomponents.org', 'www.cloudcomponents.org'],\n edgeLambdas: [originMutation],\n removalPolicy: RemovalPolicy.DESTROY,\n });\n }\n}\n```\n\n### Cloudfront Distribution\n\n```python\nnew cloudfront.Distribution(this, 'myDist', {\n defaultBehavior: {\n origin: new origins.S3Origin(myBucket),\n edgeLambdas: [httpHeaders],\n },\n});\n```\n\n### HttpHeaders\n\n```python\nconst httpHeaders = new HttpHeaders(this, 'HttpHeaders', {\n httpHeaders: {\n 'Content-Security-Policy':\n \"default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; object-src 'none'; connect-src 'self'\",\n 'Strict-Transport-Security':\n 'max-age=31536000; includeSubdomains; preload',\n 'Referrer-Policy': 'same-origin',\n 'X-XSS-Protection': '1; mode=block',\n 'X-Frame-Options': 'DENY',\n 'X-Content-Type-Options': 'nosniff',\n 'Cache-Control': 'no-cache',\n },\n});\n```\n\n### OriginMutation\n\nhttps://chrisschuld.com/2020/05/gatsby-hosting-on-cloudfront/\n\n```python\nconst originMutation = new OriginMutation(stack, 'OriginMutation');\n```\n\n## API Reference\n\nSee [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-lambda-at-edge-pattern/API.md).\n\n## Example\n\nSee more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).\n\n## License\n\n[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-lambda-at-edge-pattern/LICENSE)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "CDK Constructs for Lambda@Edge pattern: HttpHeaders",
"version": "2.3.0",
"project_urls": {
"Homepage": "https://github.com/cloudcomponents/cdk-constructs",
"Source": "https://github.com/cloudcomponents/cdk-constructs.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a5650c0302f37b64a4a09b4c09f640ecc1b73eed2433d516974bc76df8135851",
"md5": "b3d7c74a780a4c34a6770e8bc9f724c8",
"sha256": "6ee6a6eca564f8e33631e30d3895dc3a2ce48270ca64881c3c3f3f989a83a40e"
},
"downloads": -1,
"filename": "cloudcomponents.cdk_lambda_at_edge_pattern-2.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b3d7c74a780a4c34a6770e8bc9f724c8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 1740498,
"upload_time": "2024-04-17T18:35:57",
"upload_time_iso_8601": "2024-04-17T18:35:57.218897Z",
"url": "https://files.pythonhosted.org/packages/a5/65/0c0302f37b64a4a09b4c09f640ecc1b73eed2433d516974bc76df8135851/cloudcomponents.cdk_lambda_at_edge_pattern-2.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b75c5dd05d2a5d28af52bc0a0aec2c359629d6a884babbc54304ea3e28bf157a",
"md5": "3b63f93c2fb69d228b5f6558b093fefc",
"sha256": "fbab1208764fa4b46e6f637d584b55a55f8bcdcd3e13ac8d38227b499c3dfe7d"
},
"downloads": -1,
"filename": "cloudcomponents.cdk-lambda-at-edge-pattern-2.3.0.tar.gz",
"has_sig": false,
"md5_digest": "3b63f93c2fb69d228b5f6558b093fefc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 1741875,
"upload_time": "2024-04-17T18:36:02",
"upload_time_iso_8601": "2024-04-17T18:36:02.748559Z",
"url": "https://files.pythonhosted.org/packages/b7/5c/5dd05d2a5d28af52bc0a0aec2c359629d6a884babbc54304ea3e28bf157a/cloudcomponents.cdk-lambda-at-edge-pattern-2.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-17 18:36:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cloudcomponents",
"github_project": "cdk-constructs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cloudcomponents.cdk-lambda-at-edge-pattern"
}