/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */ import { IVpc , SubnetSelection , SubnetType , } from '@aws-cdk/aws-ec2' ; import { ApplicationProtocol , } from '@aws-cdk/aws-elasticloadbalancingv2' ; import { IPrivateHostedZone , } from '@aws-cdk/aws-route53' ; import { Construct , Duration , RemovalPolicy , Stack , StackProps , } from '@aws-cdk/core' ; import { SessionManagerHelper , X509CertificatePem , } from 'aws-rfdk' ; import { AwsThinkboxEulaAcceptance , RenderQueue , Repository , ThinkboxDockerImages , VersionQuery , } from 'aws-rfdk/deadline' ; /**
 * Properties for  ServiceTier .
  export interface ServiceTierProps extends StackProps { /**
     * The VPC to deploy service tier resources into.
     */ readonly vpc : IVpc ; /**
     * Whether the AWS Thinkbox End-User License Agreement is accepted or not
     */ readonly acceptAwsThinkboxEula : AwsThinkboxEulaAcceptance ; /**
     * The availability zones that components in this stack will be deployed into. These should all be in the same
     * region and only be standard availability zones, as some constucts use services that aren't available in
     * local zones yet.
     */ readonly availabilityZones : string [ ] ; /**
     * Internal DNS zone for the VPC.
     */ readonly dnsZone : IPrivateHostedZone ; /**
     * Our self-signed root CA certificate for the internal endpoints in the farm.
     */ readonly rootCa : X509CertificatePem ; default readonly deadlineVersion ? : string ; } /**
 * The service tier contains all "business-logic" constructs (e.g. Repository, Render Queue, etc.).
 */ export class ServiceTier extends Stack { /**
     * The render queue.
     */ public readonly renderQueue : RenderQueue ; /**
     * The version of Deadline configured by the app.
     */ public readonly version : VersionQuery ; /**
     * Initializes a new instance of  ServiceTier .
      constructor ( scope , id , props ) { super ( scope , id , props ) ; this . version = new VersionQuery ( this , 'Version' , { version : props . deadlineVersion , } ) ; const repositorySubnets = { availabilityZones : props . availabilityZones , subnetType : SubnetType . PRIVATE , } ; const repository = new Repository ( this , 'Repository' , { vpc : props . vpc , version : this . version , removalPolicy : { database : RemovalPolicy . DESTROY , filesystem : RemovalPolicy . DESTROY , } , repositoryInstallationTimeout : Duration . minutes ( 20 ) , vpcSubnets : repositorySubnets , } ) ; const images = new ThinkboxDockerImages ( this , 'Images' , { version : this . version , userAwsThinkboxEulaAcceptance : props . acceptAwsThinkboxEula , } ) ; const serverCert = new X509CertificatePem ( this , 'RQCert' , { subject : { cn : `renderqueue.${ props . dnsZone . zoneName }` , o : 'RFDK-Sample' , ou : 'RenderQueueExternal' , } , signingCertificate : props . rootCa , } ) ; const renderQueueSubnets = { availabilityZones : [ props . availabilityZones [ 0 ] ] , subnetType : SubnetType . PRIVATE , } ; const renderQueueAlbSubnets = { availabilityZones : props . availabilityZones , subnetType : SubnetType . PRIVATE , onePerAz : true , } ; this . renderQueue = new RenderQueue ( this , 'RenderQueue' , { vpc : props . vpc , images : images , repository , hostname : { hostname : 'renderqueue' , zone : props . dnsZone , } , trafficEncryption : { externalTLS : { rfdkCertificate : serverCert , } , internalProtocol : ApplicationProtocol . HTTPS , } , version : this . version , vpcSubnets : renderQueueSubnets , vpcSubnetsAlb : renderQueueAlbSubnets , deletionProtection : false , } ) ; SessionManagerHelper . grantPermissionsTo ( this . renderQueue . asg ) ; } }