feat: add AWS CDK stacks for domain routing, DNS records, and SSL certificates
This commit is contained in:
parent
b807f9d15a
commit
23353f2a4f
2 changed files with 96 additions and 2 deletions
|
|
@ -86,3 +86,83 @@ class MainsiteStack(Stack):
|
|||
record_name="beta",
|
||||
target=route53.RecordTarget.from_alias(targets.CloudFrontTarget(self.beta_distribution))
|
||||
)
|
||||
|
||||
# 7. CSA Website S3 Bucket
|
||||
csa_bucket = s3.Bucket(
|
||||
self, "CsaWebsiteBucket",
|
||||
bucket_name="csawebsite",
|
||||
block_public_access=s3.BlockPublicAccess.BLOCK_ALL,
|
||||
removal_policy=RemovalPolicy.RETAIN,
|
||||
)
|
||||
|
||||
# 8. CSA Website CloudFront Distribution
|
||||
self.csa_distribution = cloudfront.Distribution(
|
||||
self, "CsaWebsiteDistribution",
|
||||
default_behavior=cloudfront.BehaviorOptions(
|
||||
origin=origins.S3BucketOrigin.with_origin_access_control(csa_bucket),
|
||||
viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
||||
),
|
||||
domain_names=["csa.tradhox.com"],
|
||||
certificate=us_east_1_cert,
|
||||
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",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# 9. Beta CSA Site S3 Bucket
|
||||
betacsa_bucket = s3.Bucket(
|
||||
self, "BetaCsaSiteBucket",
|
||||
bucket_name="betacsa",
|
||||
block_public_access=s3.BlockPublicAccess.BLOCK_ALL,
|
||||
removal_policy=RemovalPolicy.RETAIN,
|
||||
)
|
||||
|
||||
# 10. Beta CSA Site CloudFront Distribution
|
||||
self.betacsa_distribution = cloudfront.Distribution(
|
||||
self, "BetaCsaSiteDistribution",
|
||||
default_behavior=cloudfront.BehaviorOptions(
|
||||
origin=origins.S3BucketOrigin.with_origin_access_control(betacsa_bucket),
|
||||
viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
||||
),
|
||||
domain_names=["betacsa.tradhox.com"],
|
||||
certificate=us_east_1_cert,
|
||||
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",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# 11. Route53 Records for CSA Site
|
||||
route53.ARecord(
|
||||
self, "CsaDomainRecord",
|
||||
zone=hosted_zone,
|
||||
record_name="csa",
|
||||
target=route53.RecordTarget.from_alias(targets.CloudFrontTarget(self.csa_distribution))
|
||||
)
|
||||
|
||||
# 12. Route53 Records for Beta CSA Site
|
||||
route53.ARecord(
|
||||
self, "BetaCsaDomainRecord",
|
||||
zone=hosted_zone,
|
||||
record_name="betacsa",
|
||||
target=route53.RecordTarget.from_alias(targets.CloudFrontTarget(self.betacsa_distribution))
|
||||
)
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ class TradhoxdomainStack(Stack):
|
|||
"betasearchengine",
|
||||
"searchengine-api",
|
||||
"betasearch-api",
|
||||
"csa",
|
||||
"betacsa",
|
||||
"apicsa",
|
||||
"betaapicsa",
|
||||
]
|
||||
|
||||
# Target IP address provided by the user
|
||||
|
|
@ -233,6 +233,20 @@ class TradhoxdomainStack(Stack):
|
|||
validation=acm.CertificateValidation.from_dns(hosted_zone),
|
||||
)
|
||||
|
||||
# SSL Certificate for apicsa.tradhox.com with Route53 DNS validation
|
||||
self.apicsa_certificate = acm.Certificate(
|
||||
self, "ApiCsaCertificate",
|
||||
domain_name="apicsa.tradhox.com",
|
||||
validation=acm.CertificateValidation.from_dns(hosted_zone),
|
||||
)
|
||||
|
||||
# SSL Certificate for betaapicsa.tradhox.com with Route53 DNS validation
|
||||
self.betaapicsa_certificate = acm.Certificate(
|
||||
self, "BetaApiCsaCertificate",
|
||||
domain_name="betaapicsa.tradhox.com",
|
||||
validation=acm.CertificateValidation.from_dns(hosted_zone),
|
||||
)
|
||||
|
||||
# SSL Certificate for tradhox.com with Route53 DNS validation
|
||||
self.tradhox_certificate = acm.Certificate(
|
||||
self, "TradhoxCertificate",
|
||||
|
|
|
|||
Loading…
Reference in a new issue