public FrontendInfrastructureStack()

in frontend-infrastructure/src/main/java/com/recognise/FrontendInfrastructureStack.java [39:69]


    public FrontendInfrastructureStack(final Construct scope, final String id, final StackProps props) {
        super(scope, id, props);

        Bucket frontendBucket = Bucket.Builder.create(this, "WebApplicationFrontendBucket")
                .websiteIndexDocument("index.html")
                .websiteErrorDocument("index.html")
                .removalPolicy(DESTROY)
                .build();

        OriginAccessIdentity accessIdentity = OriginAccessIdentity.Builder.create(this, "FrontEndOriginAccess")
                .comment("Allows Read Access from cloudfront")
                .build();

        frontendBucket.grantRead(accessIdentity);

        HostedZone hostedZone = null;
        DnsValidatedCertificate certificate = null;

        if (!contextValue("cert_domain").isEmpty()) {
            hostedZone = hostedZone();
            certificate = certificate(hostedZone);
        }

        CloudFrontWebDistribution distribution = distribution(frontendBucket, accessIdentity, certificate);

        if (null != hostedZone) {
            recordSets(hostedZone, distribution);
        }

        cloudFrontDeployment(frontendBucket, distribution);
    }