Skip to content

Commit

Permalink
Working first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgleith committed Jun 28, 2023
1 parent 462070e commit 0625e33
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 44 deletions.
20 changes: 1 addition & 19 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
#!/usr/bin/env python3
import os

import aws_cdk as cdk

from sssi.sssi_stack import SssiStack


app = cdk.App()
SssiStack(app, "SssiStack",
# If you don't specify 'env', this stack will be environment-agnostic.
# Account/Region-dependent features and context lookups will not work,
# but a single synthesized template can be deployed anywhere.

# Uncomment the next line to specialize this stack for the AWS Account
# and Region that are implied by the current CLI configuration.

#env=cdk.Environment(account=os.getenv('CDK_DEFAULT_ACCOUNT'), region=os.getenv('CDK_DEFAULT_REGION')),

# Uncomment the next line if you know exactly what Account and Region you
# want to deploy the stack to. */

#env=cdk.Environment(account='123456789012', region='us-east-1'),

# For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
)
SssiStack(app, "SssiStack")

app.synth()
13 changes: 0 additions & 13 deletions source.bat

This file was deleted.

70 changes: 58 additions & 12 deletions sssi/sssi_stack.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,65 @@
from aws_cdk import (
# Duration,
Stack,
# aws_sqs as sqs,
)
from aws_cdk import Stack
from aws_cdk import aws_certificatemanager as acm
from aws_cdk import aws_cloudfront as cloudfront
from aws_cdk import aws_s3 as s3
import aws_cdk as cdk
from constructs import Construct

class SssiStack(Stack):

# Old DNS 13.54.216.29

class SssiStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

# The code that defines your stack goes here
# Create an S3 bucket called sssi.org.au with a redirect to https://geospatialcouncil.org.au
sssi_bucket = s3.Bucket(
self,
"sssi.org.au.bucket",
bucket_name="sssi.org.au",
website_redirect=s3.RedirectTarget(
host_name="geospatialcouncil.org.au",
protocol=s3.RedirectProtocol.HTTPS,

),
removal_policy=cdk.RemovalPolicy.DESTROY
)

# Set up an ACM certificate for sssi.org.au
sssi_cert = acm.Certificate(
self,
"sssi.org.au.cert",
domain_name="sssi.org.au",
validation=acm.CertificateValidation.from_dns(),
)

# example resource
# queue = sqs.Queue(
# self, "SssiQueue",
# visibility_timeout=Duration.seconds(300),
# )
# Set up cloudfront distribution for sssi.org.au
cloudfront.CloudFrontWebDistribution(
self,
"sssi.org.au.distribution",
origin_configs=[
cloudfront.SourceConfiguration(
custom_origin_source=cloudfront.CustomOriginConfig(
domain_name=sssi_bucket.bucket_website_domain_name,
origin_protocol_policy=cloudfront.OriginProtocolPolicy.HTTP_ONLY,
),
behaviors=[
cloudfront.Behavior(
is_default_behavior=True
)
],
)
],
viewer_certificate=cloudfront.ViewerCertificate.from_acm_certificate(
certificate=sssi_cert,
aliases=["sssi.org.au"],
),
price_class=cloudfront.PriceClass.PRICE_CLASS_ALL,
error_configurations=[
cloudfront.CfnDistribution.CustomErrorResponseProperty(
error_code=404,
response_code=404,
response_page_path="/404.html",
)
],
)

0 comments on commit 0625e33

Please sign in to comment.