CDK Constructs for Lambda@Edge pattern: HttpHeaders
Project description
@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
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from aws_cdk.core import Construct, RemovalPolicy, Stack, StackProps
from aws_cdk.aws_ssm import StringParameter
from aws_cdk.aws_cloudfront import SecurityPolicyProtocol
from cloudcomponents.cdk_static_website import StaticWebsite
from cloudcomponents.cdk_lambda_at_edge_pattern import HttpHeaders
class StaticWebsiteStack(Stack):
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, synthesizer=None, terminationProtection=None):
super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection)
certificate_arn = StringParameter.value_from_lookup(self, "/certificate/cloudcomponents.org")
website = StaticWebsite(self, "StaticWebsite",
bucket_configuration=WebsiteBucketProps(
removal_policy=RemovalPolicy.DESTROY
),
alias_configuration=AliasProps(
domain_name="cloudcomponents.org",
names=["www.cloudcomponents.org", "cloudcomponents.org"],
acm_cert_ref=certificate_arn
)
)
# A us-east-1 stack is generated under the hood
http_headers = HttpHeaders(self, "HttpHeaders",
http_headers={
"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"
}
)
website.add_lambda_function_association(http_headers)
API Reference
See API.md.
Example
See more complete examples.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cloudcomponents.cdk-lambda-at-edge-pattern-1.0.3.tar.gz.
File metadata
- Download URL: cloudcomponents.cdk-lambda-at-edge-pattern-1.0.3.tar.gz
- Upload date:
- Size: 431.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a2bdc019ecd9a1d16b7d251d12d07d0ee7e17725fc79183148640a389765926
|
|
| MD5 |
df114a8ca66100cfbd43d602d470d9f7
|
|
| BLAKE2b-256 |
f06b5dceffbbe81bd9a1a92a34f9b0d75c196b90de8887a57b3c47d686fedef3
|
File details
Details for the file cloudcomponents.cdk_lambda_at_edge_pattern-1.0.3-py3-none-any.whl.
File metadata
- Download URL: cloudcomponents.cdk_lambda_at_edge_pattern-1.0.3-py3-none-any.whl
- Upload date:
- Size: 429.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7fd8cfeff17d613705a6bff800cc33553064addfbe3228d10d6cc2e6788e240
|
|
| MD5 |
88daded3dfbfc22bb9ee7b7d9178898f
|
|
| BLAKE2b-256 |
13587f08b21f9f904ed37856825a37970fa1a696e820aba8bdf0df5375b0a2c7
|