Tradhox_domain_settings/partner/partner_stack.py

31 lines
1.1 KiB
Python

from aws_cdk import (
Stack,
aws_s3 as s3,
aws_cloudfront as cloudfront,
aws_cloudfront_origins as origins,
RemovalPolicy,
)
from constructs import Construct
class PartnerStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
# 1. Create the S3 Bucket for the partner production site
partner_bucket = s3.Bucket(
self, "PartnerProductionSiteBucket",
bucket_name="partnerproductionsite",
block_public_access=s3.BlockPublicAccess.BLOCK_ALL,
removal_policy=RemovalPolicy.RETAIN,
)
# 2. Create the CloudFront Distribution with OAC (Origin Access Control)
# S3Origin automatically configures OAC for the bucket
distribution = cloudfront.Distribution(
self, "PartnerSiteDistribution",
default_behavior=cloudfront.BehaviorOptions(
origin=origins.S3Origin(partner_bucket)
),
default_root_object="index.html",
)