@cloudcomponents/cdk-lambda-at-edge-pattern
CDK Constructs for Lambda@Edge pattern: HttpHeaders
Install
TypeScript/JavaScript:
npm i @cloudcomponents/cdk-lambda-at-edge-pattern
Python:
pip install cloudcomponents.cdk-lambda-at-edge-pattern
How to use
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
new cloudfront.Distribution(this, 'myDist', {
defaultBehavior: {
origin: new origins.S3Origin(myBucket),
edgeLambdas: [httpHeaders],
},
});
HttpHeaders
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/
const originMutation = new OriginMutation(stack, 'OriginMutation');
API Reference
See API.md.
Example
See more complete examples.
License
Metadata
Release files for cloudcomponents.cdk-lambda-at-edge-pattern 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cloudcomponents.cdk-lambda-at-edge-pattern-2.3.0.tar.gz | 1.7 MB | Without provenance | Details for cloudcomponents.cdk-lambda-at-edge-pattern-2.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cloudcomponents.cdk_lambda_at_edge_pattern-2.3.0-py3-none-any.whl | Python 3 | none | any | Details for cloudcomponents.cdk_lambda_at_edge_pattern-2.3.0-py3-none-any.whl |
Total release size: 3.5 MB
Release files / cloudcomponents.cdk-lambda-at-edge-pattern-2.3.0.tar.gz
| Download URL | cloudcomponents.cdk-lambda-at-edge-pattern-2.3.0.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fbab1208764fa4b46e6f637d584b55a55f8bcdcd3e13ac8d38227b499c3dfe7d
|
|
BLAKE2b-256 checksum How to use checksums |
b75c5dd05d2a5d28af52bc0a0aec2c359629d6a884babbc54304ea3e28bf157a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / cloudcomponents.cdk_lambda_at_edge_pattern-2.3.0-py3-none-any.whl
| Download URL | cloudcomponents.cdk_lambda_at_edge_pattern-2.3.0-py3-none-any.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ee6a6eca564f8e33631e30d3895dc3a2ce48270ca64881c3c3f3f989a83a40e
|
|
BLAKE2b-256 checksum How to use checksums |
a5650c0302f37b64a4a09b4c09f640ecc1b73eed2433d516974bc76df8135851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for cloudcomponents.cdk-lambda-at-edge-pattern 2.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.