3 [&`@sPddlmZddlmZmZmZmZ dZ e ddj Z dZGdddejZd S) )core)aws_ec2 aws_sagemakeraws_efsaws_iamzlifecyclescript.shrZCDKLifeCycleConfigcs(eZdZejeddfdd ZZS)MultinotebookefsStackN)scope construct_idreturnc stj||f|tjdddtjtjjdddtjtjjdddgdd _tj j d jj d d _ t jd jddt jdt jdj d_ tjdtjdd}tjddtjdgdgdgdj|}tjj j}dtjj|ig}tjdtd|d}g} xTt t!D]H} dt"| } | j#tj$| ddj j%gjj&d j'| |j(|j)d! qWtj*d"jj+d#tj*d$j jd#fd%d&t,| DdS)'NZVPCz 10.10.0.0/16ZPublic)Z subnet_typenameZ cidr_maskZPrivate)Zmax_azscidrZsubnet_configurationZ nat_gatewaysZ securityGroupF)mutableZcommonEFS4NotebooksTZMAX_IOZBURSTING)vpcZ encryptedZenable_automatic_backupsZperformance_modeZthroughput_modeZsecurity_groupZnotebookAccessRoleZ sagemaker)Z assumed_byZnotebookAccessPolicyzs3:**)ZactionsZ resources)Z policy_nameZ statementscontentZLifeCycleConfig)'notebook_instance_lifecycle_config_nameZ on_createZon_startzCDK-Notebook-Instance-User-z ml.t2.mediumr)Z instance_typeZvolume_size_in_gbsecurity_group_ids subnet_idnotebook_instance_namerole_arnZlifecycle_config_nameZVPC_id)valueZEFS_idcs*g|]"\}}tjdt||jdqS)ZNotebookInstance_)r)r CfnOutputstrr).0cZnotebook)selfV/home/ec2-user/environment/multinotebookefs/multinotebookefs/multinotebookefs_stack.py hsz2MultinotebookefsStack.__init__..)-super__init__ec2ZVpcZSubnetConfigurationZ SubnetTypePUBLICPRIVATErZ SecurityGroupZfrom_security_group_idZvpc_default_security_groupZsgefs FileSystemZPerformanceModeZThroughputModeiam_ZRoleZServicePrincipalZPolicyZPolicyStatementZattach_to_roleLifecycleScriptStrformatZfile_system_idrFnbase64smZ"CfnNotebookInstanceLifecycleConfigLifeCycleConfigNamerange num_instancesrappendZCfnNotebookInstancesecurity_group_idZprivate_subnetsrrrrvpc_id enumerate) r!r r kwargsZnRoleZnPolicyZ encodedScriptcodeZlifecycleconfigZ instancesiZnid) __class__)r!r#r& sn     zMultinotebookefsStack.__init__)__name__ __module__ __qualname__r Constructrr& __classcell__r"r")r<r#r sr N)aws_cdkrrr'rr1rr*rr,r4openreadr-r2Stackr r"r"r"r#s