Deployment
A CloudFormation template deploys a complete Neptune Analytics + SageMaker notebook environment with a single command.
What it creates
Section titled “What it creates”- Neptune Analytics graph with configurable provisioned memory
- SageMaker notebook instance with
nx_neptunepre-installed - S3 staging bucket with versioning + KMS encryption
- KMS key for S3 bucket encryption
- IAM role and policy with Neptune, S3, KMS, Athena, Glue, and SageMaker permissions
Notebook environment variables
Section titled “Notebook environment variables”Automatically set on the notebook instance:
| Variable | Value |
|---|---|
NETWORKX_GRAPH_ID | Created graph’s ID |
AWS_REGION | Stack region |
NETWORKX_S3_EXPORT_BUCKET_PATH | s3://<bucket>/export/ |
NETWORKX_S3_IMPORT_BUCKET_PATH | s3://<bucket>/import/ |
NETWORKX_STAGING_BUCKET | s3://<bucket>/staging |
Quick deploy
Section titled “Quick deploy”-
Default deployment (installs from PyPI):
Terminal window ./cloudformation-templates/deploy.sh -
Custom stack name and region:
Terminal window ./cloudformation-templates/deploy.sh my-stack us-east-1 -
Deploy with local wheel:
Terminal window ./cloudformation-templates/deploy.sh nx-neptune-demo us-west-1 true
Script arguments
Section titled “Script arguments”| Argument | Position | Default | Description |
|---|---|---|---|
STACK_NAME | 1st | nx-neptune-demo | Stack name (max 16 chars) |
REGION | 2nd | us-west-1 | AWS region |
BUILD_WHEEL | 3rd | false | Build and deploy local wheel |
Manual deploy with AWS CLI
Section titled “Manual deploy with AWS CLI”# Build wheel and zip notebookspython -m pip wheel -w dist .zip -r /tmp/notebooks.zip notebooks/
# Upload to S3aws s3 cp dist/nx_neptune-*.whl s3://your-bucket/nx-neptune/aws s3 cp /tmp/notebooks.zip s3://your-bucket/nx-neptune/
# Deployaws cloudformation deploy \ --stack-name nx-neptune-demo \ --template-file cloudformation-templates/nx-neptune-sagemaker.json \ --capabilities CAPABILITY_NAMED_IAM \ --parameter-overrides AssetsS3Prefix=s3://your-bucket/nx-neptuneParameters
Section titled “Parameters”| Parameter | Description | Default |
|---|---|---|
ApplicationId | Resource naming prefix (max 16 chars) | nx-neptune |
ProvisionedMemory | m-NCUs for the graph (16, 32, 64) | 16 |
PublicConnectivity | Enable public connectivity | true |
NotebookInstanceType | SageMaker instance type | ml.t3.medium |
AssetsS3Prefix | S3 prefix with notebooks.zip and optional .whl | (required) |
Outputs
Section titled “Outputs”| Output | Description |
|---|---|
GraphId | Neptune Analytics graph ID |
NotebookURL | SageMaker notebook URL |
StagingBucketName | S3 bucket for import/export |
aws cloudformation describe-stacks --stack-name nx-neptune-demo --query 'Stacks[0].Outputs'Teardown
Section titled “Teardown”./cloudformation-templates/teardown.sh # defaults./cloudformation-templates/teardown.sh my-stack us-east-1 # custom- Environment variables require a notebook stop/start to update
- On every notebook start,
OnStartre-installsnx_neptune(from the.whlif provided, otherwise from PyPI)