mysql 美东时间格式_cloudcomponents.cdk-lambda-at-edge-pattern-CDK构造边缘处的Lambda图案:HttpHeaders-hupe1980 Insta...

作者:hupe1980

作者邮箱:

首页:https://github.com/cloudcomponents/cdk-constructs

文档:None

下载链接

4590e869a02714ca4212743677529923.png

@cloudcomponents/cdk-lambda-at-edge-pattern

up-c910d037d846b6deeeb16eaa585f6440.jpgup-fef6722ac539ff970a0df8e5d340a6ae.jpgup-e2046852f3910d5211ac1cfb1479c1e1.jpgup-46fd25eb69beeba000f48e23b6ee0f3b.jpg

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, analyticsReporting=None):

super().__init__(scope, id, description=description, env=env, stackName=stackName, tags=tags, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting)

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)

Cloudfront Distribution

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826

cloudfront.Distribution(self, "myDist",

default_behavior={

"origin": origins.S3Origin(my_bucket),

"edge_lambdas": [http_headers]

}

)

Cloudfront WebDistribution

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826

cloudfront.CloudFrontWebDistribution(self, "MyDistribution",

origin_configs=[{

"s3_origin_source": {

"s3_bucket_source": source_bucket

},

"behaviors": [{

"is_default_behavior": True,

"lambda_function_associations": [http_headers]

}

]

}

]

)

API Reference

Example

See more complete examples.

License

Copy from pypi.org

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值