fix(ssl): configure ACM SSL certificates and domain names for CloudFront distributions
This commit is contained in:
parent
8add9990d8
commit
cfb5cd5fd9
2 changed files with 36 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ from aws_cdk import (
|
|||
aws_s3 as s3,
|
||||
aws_cloudfront as cloudfront,
|
||||
aws_cloudfront_origins as origins,
|
||||
aws_certificatemanager as acm,
|
||||
RemovalPolicy,
|
||||
)
|
||||
from constructs import Construct
|
||||
|
|
@ -20,12 +21,21 @@ class PartnerStack(Stack):
|
|||
removal_policy=RemovalPolicy.RETAIN,
|
||||
)
|
||||
|
||||
# 2. Create the CloudFront Distribution with OAC (Origin Access Control)
|
||||
# 2. SSL Certificate in us-east-1 for partners.tradhox.com
|
||||
certificate = acm.Certificate.from_certificate_arn(
|
||||
self, "PartnerSiteCertificate",
|
||||
"arn:aws:acm:us-east-1:764709663363:certificate/e0e835c2-9ef6-4768-894c-2207b6fcfd19",
|
||||
)
|
||||
|
||||
# 3. Create the CloudFront Distribution with OAC (Origin Access Control)
|
||||
self.distribution = cloudfront.Distribution(
|
||||
self, "PartnerSiteDistribution",
|
||||
default_behavior=cloudfront.BehaviorOptions(
|
||||
origin=origins.S3BucketOrigin.with_origin_access_control(partner_bucket)
|
||||
origin=origins.S3BucketOrigin.with_origin_access_control(partner_bucket),
|
||||
viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
||||
),
|
||||
domain_names=["partners.tradhox.com"],
|
||||
certificate=certificate,
|
||||
default_root_object="index.html",
|
||||
error_responses=[
|
||||
cloudfront.ErrorResponse(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from aws_cdk import (
|
|||
aws_s3 as s3,
|
||||
aws_cloudfront as cloudfront,
|
||||
aws_cloudfront_origins as origins,
|
||||
aws_certificatemanager as acm,
|
||||
RemovalPolicy,
|
||||
)
|
||||
from constructs import Construct
|
||||
|
|
@ -20,11 +21,32 @@ class ShoppingStack(Stack):
|
|||
removal_policy=RemovalPolicy.RETAIN,
|
||||
)
|
||||
|
||||
# 2. Create the CloudFront Distribution with OAC (Origin Access Control)
|
||||
# 2. SSL Certificate in us-east-1 for tradhox.com and *.tradhox.com
|
||||
certificate = acm.Certificate.from_certificate_arn(
|
||||
self, "ShoppingSiteCertificate",
|
||||
"arn:aws:acm:us-east-1:764709663363:certificate/037281b1-e7ef-416e-af27-54dbc34cf6c3",
|
||||
)
|
||||
|
||||
# 3. Create the CloudFront Distribution with OAC (Origin Access Control)
|
||||
self.distribution = cloudfront.Distribution(
|
||||
self, "ShoppingSiteDistribution",
|
||||
default_behavior=cloudfront.BehaviorOptions(
|
||||
origin=origins.S3BucketOrigin.with_origin_access_control(shopping_bucket)
|
||||
origin=origins.S3BucketOrigin.with_origin_access_control(shopping_bucket),
|
||||
viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
||||
),
|
||||
domain_names=["tradhox.com", "www.tradhox.com"],
|
||||
certificate=certificate,
|
||||
default_root_object="index.html",
|
||||
error_responses=[
|
||||
cloudfront.ErrorResponse(
|
||||
http_status=403,
|
||||
response_http_status=200,
|
||||
response_page_path="/index.html",
|
||||
),
|
||||
cloudfront.ErrorResponse(
|
||||
http_status=404,
|
||||
response_http_status=200,
|
||||
response_page_path="/index.html",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue