UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 6.13 kB
"use strict";var __runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AccessPointReflection=void 0;var core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},helpers_internal_1=()=>{var tmp=require("../../../core/lib/helpers-internal");return helpers_internal_1=()=>tmp,tmp},literal_string_1=()=>{var tmp=require("../../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp},s3files_generated_1=()=>{var tmp=require("../s3files.generated");return s3files_generated_1=()=>tmp,tmp};let AccessPointReflection=(()=>{let _instanceExtraInitializers=[],_get_fileSystem_decorators,_get_mountTargets_decorators,_get_mountTargetSecurityGroups_decorators;return class AccessPointReflection2{static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;_get_fileSystem_decorators=[helpers_internal_1().memoizedGetter],_get_mountTargets_decorators=[helpers_internal_1().memoizedGetter],_get_mountTargetSecurityGroups_decorators=[helpers_internal_1().memoizedGetter],__esDecorate(this,null,_get_fileSystem_decorators,{kind:"getter",name:"fileSystem",static:!1,private:!1,access:{has:obj=>"fileSystem"in obj,get:obj=>obj.fileSystem},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_get_mountTargets_decorators,{kind:"getter",name:"mountTargets",static:!1,private:!1,access:{has:obj=>"mountTargets"in obj,get:obj=>obj.mountTargets},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,_get_mountTargetSecurityGroups_decorators,{kind:"getter",name:"mountTargetSecurityGroups",static:!1,private:!1,access:{has:obj=>"mountTargetSecurityGroups"in obj,get:obj=>obj.mountTargetSecurityGroups},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static of(accessPointRef){return new AccessPointReflection2(accessPointRef)}ref=__runInitializers(this,_instanceExtraInitializers);_accessPoint;constructor(accessPointRef){this.ref=accessPointRef,this._accessPoint=helpers_internal_1().ConstructReflection.of(accessPointRef).findCfnResource({cfnResourceType:"AWS::S3Files::AccessPoint",matches:candidate=>candidate.accessPointRef?.accessPointId===accessPointRef.accessPointRef.accessPointId})}get accessPoint(){if(!this._accessPoint)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`CfnAccessPointNotFound`,`Unable to find underlying CfnAccessPoint for ${this.ref.node.path}.`);return this._accessPoint}get fileSystem(){const ap=this.accessPoint,fs=helpers_internal_1().ConstructReflection.of(ap).findRelatedCfnResource({cfnResourceType:"AWS::S3Files::FileSystem",matches:candidate=>{const cfnFs=candidate;return ap.fileSystemId===cfnFs.ref||ap.fileSystemId===cfnFs.attrFileSystemId}});if(!fs)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`CfnFileSystemNotFound`,`Unable to find the CfnFileSystem for access point at ${ap.node.path}. Ensure the file system is defined in the same CDK app and linked to the access point.`);return fs}get mountTargets(){const fs=this.fileSystem,result=[];for(const child of this.ref.node.root.node.findAll())s3files_generated_1().CfnMountTarget.isCfnMountTarget(child)&&(child.fileSystemId===fs.ref||child.fileSystemId===fs.attrFileSystemId)&&result.push(child);if(result.length===0)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`MountTargetsNotFound`,`No mount targets found for file system at ${fs.node.path}. Create at least one CfnMountTarget for the file system.`);return result}get mountTargetSecurityGroups(){const securityGroups=[],seen=new Set;for(const mountTarget of this.mountTargets){if(!mountTarget.securityGroups||mountTarget.securityGroups.length===0)throw new(core_1()).UnscopedValidationError((0,literal_string_1().lit)`MountTargetMissingSecurityGroups`,`Mount target ${mountTarget.node.path} does not have security groups. Add security groups to the mount target.`);for(const securityGroupId of mountTarget.securityGroups){if(seen.has(securityGroupId))continue;seen.add(securityGroupId);const cfnSecurityGroup=helpers_internal_1().ConstructReflection.of(mountTarget).findRelatedCfnResource({cfnResourceType:"AWS::EC2::SecurityGroup",matches:candidate=>candidate.ref===securityGroupId||candidate.attrGroupId===securityGroupId});cfnSecurityGroup&&securityGroups.push(cfnSecurityGroup)}}return securityGroups}}})();exports.AccessPointReflection=AccessPointReflection;