/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */ import { FlowLogDestination , FlowLogTrafficType , GatewayVpcEndpointAwsService , IInterfaceVpcEndpointService , IGatewayVpcEndpointService , InterfaceVpcEndpointAwsService , IVpc , SubnetSelection , SubnetType , Vpc , } from '@aws-cdk/aws-ec2' ; import { PrivateHostedZone , } from '@aws-cdk/aws-route53' ; import * as cdk from '@aws-cdk/core' ; import { Subnets } from './subnets' ; /**
 * The network tier consists of all constructs that are required for the foundational
 * networking between the various components of the Deadline render farm.
 */ export class NetworkTier extends cdk . Stack { /**
     * The VPC that all components of the render farm will be created in.
     */ public readonly vpc : IVpc ; /**
     * Internal DNS zone for the VPC.
     */ public readonly dnsZone : PrivateHostedZone ; /**
     * The interface endpoints for the AWS services used in this app.
     */ private static readonly INTERFACE_ENDPOINT_SERVICES : { name : string ; service : IInterfaceVpcEndpointService ; } [ ] = [ { name : 'CLOUDWATCH' , service : InterfaceVpcEndpointAwsService . CLOUDWATCH } , { name : 'CLOUDWATCH_EVENTS' , service : InterfaceVpcEndpointAwsService . CLOUDWATCH_EVENTS } , { name : 'CLOUDWATCH_LOGS' , service : InterfaceVpcEndpointAwsService . CLOUDWATCH_LOGS } , { name : 'EC2' , service : InterfaceVpcEndpointAwsService . EC2 } , { name : 'ECR' , service : InterfaceVpcEndpointAwsService . ECR } , { name : 'ECS' , service : InterfaceVpcEndpointAwsService . ECS } , { name : 'KMS' , service : InterfaceVpcEndpointAwsService . KMS } , { name : 'SECRETS_MANAGER' , service : InterfaceVpcEndpointAwsService . SECRETS_MANAGER } , { name : 'SNS' , service : InterfaceVpcEndpointAwsService . SNS } , { name : 'STS' , service : InterfaceVpcEndpointAwsService . STS } , ] ; /**
     * The gateway endpoints for the AWS services used in this app.
     */ private static readonly GATEWAY_ENDPOINT_SERVICES : { name : string ; service : IGatewayVpcEndpointService ; } [ ] = [ { name : 'S3' , service : GatewayVpcEndpointAwsService . S3 } , { name : 'DYNAMODB' , service : GatewayVpcEndpointAwsService . DYNAMODB } , ] ; /**
     * Initializes a new instance of  NetworkTier .
     *  param scope param id param props constructor ( scope , id , props ? ) { super ( scope , id , props ) ; this . vpc = new Vpc ( this , 'Vpc' , { maxAzs : 2 , subnetConfiguration : [ Subnets . INFRASTRUCTURE , Subnets . PUBLIC , Subnets . RENDER_QUEUE_ALB , Subnets . USAGE_BASED_LICENSING , Subnets . WORKERS , ] , flowLogs : { 'NetworkTierFlowLogs' : { trafficType : FlowLogTrafficType . ALL , destination : FlowLogDestination . toCloudWatchLogs ( ) , } , } , } ) ; const endpointSubnets = { subnetType : SubnetType . PRIVATE } ; NetworkTier . INTERFACE_ENDPOINT_SERVICES . forEach ( ( serviceInfo , idx ) => { this . vpc . addInterfaceEndpoint ( `${ serviceInfo . name }${ idx }` , { service : serviceInfo . service , subnets : endpointSubnets , } ) ; } ) ; NetworkTier . GATEWAY_ENDPOINT_SERVICES . forEach ( serviceInfo => { this . vpc . addGatewayEndpoint ( serviceInfo . name , { service : serviceInfo . service , subnets : [ endpointSubnets ] , } ) ; } ) ; this . dnsZone = new PrivateHostedZone ( this , 'DnsZone' , { vpc : this . vpc , zoneName : 'deadline-test.internal' , } ) ; } }