@@ -68,22 +68,22 @@ Parameters:
6868 VPC :
6969 Description : VPC to launch the Cluster nodes
7070 Type : String
71- Default : vpc-07c351be7a033127f
71+ Default : vpc-0e80ca11ecebc561d
7272
7373 DefaultPrivateSubnet :
7474 Description : Private subnet for the PCluster
7575 Type : String
76- Default : subnet-01d831eb711ef25ec
76+ Default : subnet-005ed22f10a495974
7777
7878 SecurityGroup :
7979 Description : Security group ID from the network template output
8080 Type : String
81- Default : sg-00db64cee7ba85cb2
81+ Default : sg-08ccbf9fa55387782
8282
8383 DefaultPublicSubnet :
84- Description : Private subnet for the PCluster
84+ Description : Public subnet for the PCluster (must route to an Internet Gateway if used)
8585 Type : String
86- Default : subnet-01d831eb711ef25ec
86+ Default : subnet-0f126c0751ec4b3aa
8787
8888 # Parameters for pcs-iip-minimal.yaml
8989 EnableSsm :
@@ -112,7 +112,7 @@ Parameters:
112112 VpcDefaultSecurityGroupId :
113113 Type : AWS::EC2::SecurityGroup::Id
114114 Description : Cluster VPC 'default' security group. Make sure you choose the one from your cluster VPC!
115- Default : sg-00db64cee7ba85cb2 # Default from main stack's SecurityGroup param
115+ Default : sg-08ccbf9fa55387782 # Default from main stack's SecurityGroup param
116116
117117 EfsFilesystemId :
118118 Type : String
@@ -155,6 +155,20 @@ Parameters:
155155 Description : Project tag to apply to nested stacks
156156 Default : " Placeholder"
157157
158+ IamPolicyDocument :
159+ Type : String
160+ Description : The IAM policy to be associated with the launched workstation
161+
162+ S3Mounts :
163+ Type : String
164+ Description : A JSON array of objects with name, bucket, and prefix properties used to mount data
165+
166+ EnvironmentInstanceFiles :
167+ Type : String
168+ Description : >-
169+ An S3 URI (starting with "s3://") that specifies the location of files to be copied to
170+ the environment instance, including any bootstrap scripts
171+
158172
159173Conditions :
160174 HasAccountingSupport : !Not [!Or [!Equals [!Ref SlurmVersion, "23.11"], !Equals [!Ref SlurmVersion, "24.05"]]]
@@ -165,6 +179,7 @@ Conditions:
165179 EnableS3ReadOnlyCondition : !Equals [!Ref EnableS3ReadOnly, "True"]
166180 EnableCloudwatchAgentCondition : !Equals [!Ref EnableCloudwatchAgent, "True"]
167181 CreateSshSecGroup : !Equals [!Ref CreateInboundSshSecurityGroup, 'True']
182+ IamPolicyEmpty : !Equals [!Ref IamPolicyDocument, '{}']
168183
169184Mappings :
170185 Architecture :
@@ -173,10 +188,10 @@ Mappings:
173188 x86 : x86_64
174189 LoginNodeInstances :
175190 Graviton : c7g.xlarge
176- x86 : g4dn.2xlarge
191+ x86 : t3.medium
177192 ComputeNodeInstances :
178193 Graviton : c7g.xlarge
179- x86 : g4dn.2xlarge
194+ x86 : t3.medium
180195
181196Resources :
182197 # Merged from pcs-cluster-sg.yaml
@@ -196,6 +211,10 @@ Resources:
196211 FromPort : 0
197212 ToPort : 65535
198213 CidrIp : 0.0.0.0/0 # Allow all incoming traffic (adjust as needed for security)
214+ SecurityGroupEgress :
215+ # Allow all outbound traffic so instances can reach AWS services and the internet
216+ - IpProtocol : ' -1'
217+ CidrIp : 0.0.0.0/0
199218
200219 ClusterAllowAllInboundFromSelf :
201220 Type : AWS::EC2::SecurityGroupIngress
@@ -218,6 +237,7 @@ Resources:
218237 GroupId : !Ref ClusterSecurityGroup
219238 IpProtocol : ' -1'
220239 CidrIp : 0.0.0.0/0
240+ # (Outbound to world now defined inline in ClusterSecurityGroup.SecurityGroupEgress)
221241
222242 # Attach this to login nodes to enable inbound SSH access.
223243 InboundSshSecurityGroup :
@@ -266,6 +286,11 @@ Resources:
266286 - " arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
267287 - !Ref AWS::NoValue
268288 Policies :
289+ - !If
290+ - IamPolicyEmpty
291+ - !Ref AWS::NoValue
292+ - PolicyName : !Sub '${AWS::StackName}-s3-studydata-policy'
293+ PolicyDocument : !Ref IamPolicyDocument
269294 - PolicyDocument :
270295 Version : " 2012-10-17"
271296 Statement :
@@ -274,6 +299,13 @@ Resources:
274299 Effect : Allow
275300 Resource : " *"
276301 PolicyName : PcsRegisterInstancePolicy
302+ - PolicyDocument :
303+ Version : " 2012-10-17"
304+ Statement :
305+ - Action : " kms:*"
306+ Effect : Allow
307+ Resource : " *"
308+ PolicyName : PcsKmsFullAccessPolicy
277309 Tags :
278310 - Key : cost_resource
279311 Value : !Sub '${AWS::StackName}'
@@ -339,16 +371,26 @@ Resources:
339371 # - mount -a -t efs defaults
340372 # - rsync -aA --ignore-existing /tmp/home/ /home
341373 # - rm -rf /tmp/home/
342- # !/bin/bash
343- mkdir -p /var/log/amazon/pcs
344- exec > >(tee -a /var/log/amazon/pcs/bootstrap.log | logger -t user-data -s 2>/dev/ttyS0) 2>&1
345-
346- mkdir -p /etc/amazon/pcs
347- echo '{ "cluster" : { "version": "Slurm_24.11", "disable_multithreading": true, "scheduler": "slurm", "base_os": "alinux2", "cluster_id": "${AWS::StackName}", "slurm": { "endpoint": "https://pcs.${AWS::Region}.api.aws" }}}' > /etc/amazon/pcs/bootstrap_config.json
348-
349- cloud-init-per instance pcs-bootstrap-init /opt/aws/pcs/bin/pcs_bootstrap_init.sh /etc/amazon/pcs/bootstrap_config.json
350- cloud-init-per instance pcs-bootstrap-config /opt/aws/pcs/bin/pcs_bootstrap_config_per_instance.sh /etc/amazon/pcs/bootstrap_config.json
351- /opt/aws/pcs/bin/pcs_bootstrap_finalize.sh /etc/amazon/pcs/bootstrap_config.json
374+ - mkdir -p /var/log/amazon/pcs
375+ - mkdir -p /etc/amazon/pcs
376+ - |
377+ cat > /etc/amazon/pcs/bootstrap_config.json <<'EOF'
378+ { "cluster": { "version": "Slurm_24.11", "disable_multithreading": true, "scheduler": "slurm", "base_os": "alinux2", "cluster_id": "${AWS::StackName}", "slurm": { "endpoint": "https://pcs.${AWS::Region}.api.aws" }}}
379+ EOF
380+ - cloud-init-per instance pcs-bootstrap-init /opt/aws/pcs/bin/pcs_bootstrap_init.sh /etc/amazon/pcs/bootstrap_config.json
381+ - cloud-init-per instance pcs-bootstrap-config /opt/aws/pcs/bin/pcs_bootstrap_config_per_instance.sh /etc/amazon/pcs/bootstrap_config.json
382+ - /opt/aws/pcs/bin/pcs_bootstrap_finalize.sh /etc/amazon/pcs/bootstrap_config.json
383+ - bash -lc 'printf "%s\n" "#!/bin/bash" "touch /home/ec2-user/mount_s3.log" "mount_s3.sh >> /home/ec2-user/mount_s3.log 2>&1" > /home/ec2-user/mount_study.sh'
384+ - chmod 755 /home/ec2-user/mount_study.sh
385+ - chown ec2-user:ec2-user /home/ec2-user/mount_study.sh
386+ - touch /home/ec2-user/mount_s3.log
387+ - chown ec2-user:ec2-user /home/ec2-user/mount_s3.log
388+ - chmod 644 /home/ec2-user/mount_s3.log
389+ - bash -lc 'crontab -l 2>/dev/null > /tmp/crontab || true; if ! grep -Fq "/home/ec2-user/mount_study.sh" /tmp/crontab; then echo "@reboot sudo -u ec2-user /home/ec2-user/mount_study.sh" >> /tmp/crontab; crontab /tmp/crontab; fi'
390+ - aws s3 cp --region "${AWS::Region}" "${EnvironmentInstanceFiles}/get_bootstrap.sh" "/tmp"
391+ - chmod 500 /tmp/get_bootstrap.sh
392+ - /tmp/get_bootstrap.sh "${EnvironmentInstanceFiles}" '${S3Mounts}'
393+ - sudo -u ec2-user /home/ec2-user/mount_study.sh
352394
353395 # If provided, mount FSxL filesystem as /shared
354396 # - if [ ! -z "${FSxLustreFilesystemId}" ]; then amazon-linux-extras install -y lustre=latest; mkdir -p /shared; chmod a+rwx /shared; mount -t lustre ${FSxLustreFilesystemId}.fsx.${AWS::Region}.amazonaws.com@tcp:/${FSxLustreFilesystemMountName} /shared; chmod 777 /shared; fi
@@ -401,16 +443,15 @@ Resources:
401443 # - mount -a -t efs defaults
402444 # - rsync -aA --ignore-existing /tmp/home/ /home
403445 # - rm -rf /tmp/home/
404- # !/bin/bash
405- mkdir -p /var/log/amazon/pcs
406- exec > >(tee -a /var/log/amazon/pcs/bootstrap.log | logger -t user-data -s 2>/dev/ttyS0) 2>&1
407-
408- mkdir -p /etc/amazon/pcs
409- echo '{ "cluster" : { "version": "Slurm_24.11", "disable_multithreading": true, "scheduler": "slurm", "base_os": "alinux2", "cluster_id": "${AWS::StackName}", "slurm": { "endpoint": "https://pcs.${AWS::Region}.api.aws" }}}' > /etc/amazon/pcs/bootstrap_config.json
410-
411- cloud-init-per instance pcs-bootstrap-init /opt/aws/pcs/bin/pcs_bootstrap_init.sh /etc/amazon/pcs/bootstrap_config.json
412- cloud-init-per instance pcs-bootstrap-config /opt/aws/pcs/bin/pcs_bootstrap_config_per_instance.sh /etc/amazon/pcs/bootstrap_config.json
413- /opt/aws/pcs/bin/pcs_bootstrap_finalize.sh /etc/amazon/pcs/bootstrap_config.json
446+ - mkdir -p /var/log/amazon/pcs
447+ - mkdir -p /etc/amazon/pcs
448+ - |
449+ cat > /etc/amazon/pcs/bootstrap_config.json <<'EOF'
450+ { "cluster": { "version": "Slurm_24.11", "disable_multithreading": true, "scheduler": "slurm", "base_os": "alinux2", "cluster_id": "${AWS::StackName}", "slurm": { "endpoint": "https://pcs.${AWS::Region}.api.aws" }}}
451+ EOF
452+ - cloud-init-per instance pcs-bootstrap-init /opt/aws/pcs/bin/pcs_bootstrap_init.sh /etc/amazon/pcs/bootstrap_config.json
453+ - cloud-init-per instance pcs-bootstrap-config /opt/aws/pcs/bin/pcs_bootstrap_config_per_instance.sh /etc/amazon/pcs/bootstrap_config.json
454+ - /opt/aws/pcs/bin/pcs_bootstrap_finalize.sh /etc/amazon/pcs/bootstrap_config.json
414455
415456 # If provided, mount FSxL filesystem as /shared
416457 # - if [ ! -z "${FSxLustreFilesystemId}" ]; then amazon-linux-extras install -y lustre=latest; mkdir -p /shared; chmod a+rwx /shared; mount -t lustre ${FSxLustreFilesystemId}.fsx.${AWS::Region}.amazonaws.com@tcp:/${FSxLustreFilesystemMountName} /shared; fi
@@ -460,10 +501,10 @@ Resources:
460501 IamInstanceProfileArn : !GetAtt [PcsInstanceProfile, Arn] # Converted from nested stack output
461502 CustomLaunchTemplate :
462503 TemplateId : !Ref LoginLaunchTemplate # Converted from nested stack output
463- Version : 1
504+ Version : !GetAtt LoginLaunchTemplate.LatestVersionNumber
464505 SubnetIds :
465506 - !Ref DefaultPublicSubnet
466- AmiId : ami-0bf564070da947c48
507+ AmiId : ami-08608e2b2243c1f1b
467508 InstanceConfigs :
468509 - InstanceType : !FindInMap [Architecture, LoginNodeInstances, !Ref NodeArchitecture]
469510
@@ -481,10 +522,10 @@ Resources:
481522 IamInstanceProfileArn : !GetAtt [PcsInstanceProfile, Arn] # Converted from nested stack output
482523 CustomLaunchTemplate :
483524 TemplateId : !Ref ComputeLaunchTemplate # Converted from nested stack output
484- Version : 1
525+ Version : !GetAtt ComputeLaunchTemplate.LatestVersionNumber
485526 SubnetIds :
486527 - !Ref DefaultPrivateSubnet
487- AmiId : ami-0bf564070da947c48
528+ AmiId : ami-08608e2b2243c1f1b
488529 InstanceConfigs :
489530 - InstanceType : !FindInMap [Architecture, ComputeNodeInstances, !Ref NodeArchitecture]
490531
0 commit comments