|
| 1 | +AWSTemplateFormatVersion: '2010-09-09' |
| 2 | + |
| 3 | +Description: A template to deploy Neptune Notebooks using CloudFormation resources. |
| 4 | + |
| 5 | +Parameters: |
| 6 | + NotebookInstanceType: |
| 7 | + Description: The notebook instance type. |
| 8 | + Type: String |
| 9 | + Default: ml.t2.medium |
| 10 | + AllowedValues: |
| 11 | + - ml.t2.medium |
| 12 | + - ml.t2.large |
| 13 | + - ml.t2.xlarge |
| 14 | + - ml.t2.2xlarge |
| 15 | + - ml.t3.2xlarge |
| 16 | + - ml.t3.large |
| 17 | + - ml.t3.medium |
| 18 | + - ml.t3.xlarge |
| 19 | + - ml.m4.xlarge |
| 20 | + - ml.m4.2xlarge |
| 21 | + - ml.m4.4xlarge |
| 22 | + - ml.m4.10xlarge |
| 23 | + - ml.m4.16xlarge |
| 24 | + - ml.m5.12xlarge |
| 25 | + - ml.m5.24xlarge |
| 26 | + - ml.m5.2xlarge |
| 27 | + - ml.m5.4xlarge |
| 28 | + - ml.m5.xlarge |
| 29 | + - ml.p2.16xlarge |
| 30 | + - ml.p2.8xlarge |
| 31 | + - ml.p2.xlarge |
| 32 | + - ml.p3.16xlarge |
| 33 | + - ml.p3.2xlarge |
| 34 | + - ml.p3.8xlarge |
| 35 | + - ml.c4.2xlarge |
| 36 | + - ml.c4.4xlarge |
| 37 | + - ml.c4.8xlarge |
| 38 | + - ml.c4.xlarge |
| 39 | + - ml.c5.18xlarge |
| 40 | + - ml.c5.2xlarge |
| 41 | + - ml.c5.4xlarge |
| 42 | + - ml.c5.9xlarge |
| 43 | + - ml.c5.xlarge |
| 44 | + - ml.c5d.18xlarge |
| 45 | + - ml.c5d.2xlarge |
| 46 | + - ml.c5d.4xlarge |
| 47 | + - ml.c5d.9xlarge |
| 48 | + - ml.c5d.xlarge |
| 49 | + ConstraintDescription: Must be a valid SageMaker instance type. |
| 50 | + |
| 51 | + NeptuneClusterEndpoint: |
| 52 | + Description: The cluster endpoint of an existing Neptune cluster. |
| 53 | + Type: String |
| 54 | + |
| 55 | + NeptuneClusterPort: |
| 56 | + Description: 'OPTIONAL: The Port of an existing Neptune cluster (default 8182).' |
| 57 | + Type: String |
| 58 | + Default: '8182' |
| 59 | + |
| 60 | + NeptuneClusterSecurityGroups: |
| 61 | + Description: The VPC security group IDs. The security groups must be for the same VPC as specified in the subnet. |
| 62 | + Type: List<AWS::EC2::SecurityGroup::Id> |
| 63 | + |
| 64 | + NeptuneClusterSubnetId: |
| 65 | + Description: The ID of the subnet in a VPC to which you would like to have a connectivity from your ML compute instance. |
| 66 | + Type: AWS::EC2::Subnet::Id |
| 67 | + |
| 68 | + SageMakerNotebookRole: |
| 69 | + Description: The ARN for the IAM role that the notebook instance will assume. |
| 70 | + Type: String |
| 71 | + AllowedPattern: ^arn:aws[a-z\-]*:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+$ |
| 72 | + |
| 73 | + SageMakerNotebookName: |
| 74 | + Description: The name of the Neptune notebook. |
| 75 | + Type: String |
| 76 | + |
| 77 | +Resources: |
| 78 | + NeptuneNotebookInstance: |
| 79 | + Type: AWS::SageMaker::NotebookInstance |
| 80 | + Properties: |
| 81 | + NotebookInstanceName: !Join |
| 82 | + - '' |
| 83 | + - - 'aws-neptune-' |
| 84 | + - !Ref SageMakerNotebookName |
| 85 | + InstanceType: |
| 86 | + Ref: NotebookInstanceType |
| 87 | + SubnetId: |
| 88 | + Ref: NeptuneClusterSubnetId |
| 89 | + SecurityGroupIds: |
| 90 | + Ref: NeptuneClusterSecurityGroups |
| 91 | + RoleArn: |
| 92 | + Ref: SageMakerNotebookRole |
| 93 | + LifecycleConfigName: |
| 94 | + Fn::GetAtt: |
| 95 | + - NeptuneNotebookInstanceLifecycleConfig |
| 96 | + - NotebookInstanceLifecycleConfigName |
| 97 | + |
| 98 | + NeptuneNotebookInstanceLifecycleConfig: |
| 99 | + Type: AWS::SageMaker::NotebookInstanceLifecycleConfig |
| 100 | + Properties: |
| 101 | + OnStart: |
| 102 | + - Content: |
| 103 | + Fn::Base64: |
| 104 | + Fn::Join: |
| 105 | + - '' |
| 106 | + - - "#!/bin/bash\n" |
| 107 | + - sudo -u ec2-user -i << 'EOF' |
| 108 | + - "\n" |
| 109 | + - echo 'export GRAPH_NOTEBOOK_AUTH_MODE= |
| 110 | + - "DEFAULT' >> ~/.bashrc\n" |
| 111 | + - echo 'export GRAPH_NOTEBOOK_HOST= |
| 112 | + - !Ref NeptuneClusterEndpoint |
| 113 | + - "' >> ~/.bashrc\n" |
| 114 | + - echo 'export GRAPH_NOTEBOOK_PORT= |
| 115 | + - !Ref NeptuneClusterPort |
| 116 | + - "' >> ~/.bashrc\n" |
| 117 | + - echo 'export NEPTUNE_LOAD_FROM_S3_ROLE_ARN= |
| 118 | + - "' >> ~/.bashrc\n" |
| 119 | + - echo 'export AWS_REGION= |
| 120 | + - !Ref AWS::Region |
| 121 | + - "' >> ~/.bashrc\n" |
| 122 | + - aws s3 cp s3://aws-neptune-notebook/graph_notebook.tar.gz /tmp/graph_notebook.tar.gz |
| 123 | + - "\n" |
| 124 | + - rm -rf /tmp/graph_notebook |
| 125 | + - "\n" |
| 126 | + - tar -zxvf /tmp/graph_notebook.tar.gz -C /tmp |
| 127 | + - "\n" |
| 128 | + - /tmp/graph_notebook/install.sh |
| 129 | + - "\n" |
| 130 | + - EOF |
0 commit comments