CDK Constructs for Lambda@Edge pattern
Project description
@cloudcomponents/cdk-lambda-at-edge-pattern
[](https://pypi.org/project/cloudcomponents.cdk-lambda-at-edge-pattern /)
CDK Constructs for Lambda@Edge pattern
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](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-lambda-at-edge-pattern /API.md).
Example
See more complete examples.
License
[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-lambda-at-edge-pattern /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
Close
Hashes for cloudcomponents.cdk-lambda-at-edge-pattern-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cd818100227255966123f9bf8847f2993d30532327dc4523da9db9fe2404f96 |
|
MD5 | e6d9e316027dc463e2a40711b83f7e48 |
|
BLAKE2b-256 | f4b6ba4aab0b07a96e425079428f166752d2e4fdf66fd1fa0d493a659315a2d6 |
Close
Hashes for cloudcomponents.cdk_lambda_at_edge_pattern-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a19bd70745bd977e7396db04c3e7dec0bb5b05eded7a1c1057aa64df4405f63 |
|
MD5 | e10c148f9faafe4eed160159322ec67c |
|
BLAKE2b-256 | 5d38f307512f9a148b59947f70da9375f15b48bbe63e7c59681368032164f727 |