"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.VpcEndpointService=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),region_info_1=require("../../region-info"),ec2_generated_1=require("./ec2.generated");class VpcEndpointService extends core_1.Resource{constructor(scope,id,props){var _b,_c,_d,_e;super(scope,id);if(jsiiDeprecationWarnings.aws_cdk_lib_aws_ec2_VpcEndpointServiceProps(props),props.vpcEndpointServiceLoadBalancers===void 0||props.vpcEndpointServiceLoadBalancers.length===0)throw new Error("VPC Endpoint Service must have at least one load balancer specified.");if(this.vpcEndpointServiceLoadBalancers=props.vpcEndpointServiceLoadBalancers,this.acceptanceRequired=(_b=props.acceptanceRequired)!==null&&_b!==void 0?_b:!0,props.allowedPrincipals&&props.whitelistedPrincipals)throw new Error("`whitelistedPrincipals` is deprecated; please use `allowedPrincipals` instead");this.allowedPrincipals=(_d=(_c=props.allowedPrincipals)!==null&&_c!==void 0?_c:props.whitelistedPrincipals)!==null&&_d!==void 0?_d:[],this.whitelistedPrincipals=this.allowedPrincipals,this.endpointService=new ec2_generated_1.CfnVPCEndpointService(this,id,{networkLoadBalancerArns:this.vpcEndpointServiceLoadBalancers.map(lb=>lb.loadBalancerArn),acceptanceRequired:this.acceptanceRequired}),this.vpcEndpointServiceId=this.endpointService.ref;const{region}=core_1.Stack.of(this),serviceNamePrefix=core_1.Token.isUnresolved(region)?region_info_1.Default.VPC_ENDPOINT_SERVICE_NAME_PREFIX:(_e=region_info_1.RegionInfo.get(region).vpcEndpointServiceNamePrefix)!==null&&_e!==void 0?_e:region_info_1.Default.VPC_ENDPOINT_SERVICE_NAME_PREFIX;this.vpcEndpointServiceName=core_1.Fn.join(".",[serviceNamePrefix,core_1.Aws.REGION,this.vpcEndpointServiceId]),this.allowedPrincipals.length>0&&new ec2_generated_1.CfnVPCEndpointServicePermissions(this,"Permissions",{serviceId:this.endpointService.ref,allowedPrincipals:this.allowedPrincipals.map(x=>x.arn)})}}exports.VpcEndpointService=VpcEndpointService,_a=JSII_RTTI_SYMBOL_1,VpcEndpointService[_a]={fqn:"aws-cdk-lib.aws_ec2.VpcEndpointService",version:"2.13.0"};
//# sourceMappingURL=vpc-endpoint-service.js.map
