Skip to content

Commit 8c95bae

Browse files
authored
Use regional S3 bucket mappings in Neptune CloudFormation template (#664)
* Use regional S3 bucket mappings in Neptune CloudFormation template * Revise mappings * update changelog
1 parent e5fafc1 commit 8c95bae

File tree

2 files changed

+91
-17
lines changed

2 files changed

+91
-17
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd
44

55
## Upcoming
66

7+
- Added regional S3 bucket mappings to Neptune CloudFormation template ([Link to PR](https://github.com/aws/graph-notebook/pull/664))
78
- Enabled n-triples data for `%load` with Neptune Analytics ([Link to PR](https://github.com/aws/graph-notebook/pull/671))
89
- Removed unused options from `%load`([Link to PR](https://github.com/aws/graph-notebook/pull/662))
910
- Made EncryptionKey optional in Neptune CloudFormation template ([Link to PR](https://github.com/aws/graph-notebook/pull/663))

additional-databases/sagemaker/neptune-notebook-cloudformation/neptune-workbench-stack.yaml

Lines changed: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,61 @@ Conditions:
107107
- Ref: EncryptionKey
108108
- ""
109109

110+
Mappings:
111+
RegionMap:
112+
cn-north-1:
113+
"bucket": "aws-neptune-notebook-cn-north-1"
114+
cn-northwest-1:
115+
"bucket": "aws-neptune-notebook-cn-northwest-1"
116+
us-east-2:
117+
"bucket": "aws-neptune-notebook-us-east-2"
118+
us-east-1:
119+
"bucket": "aws-neptune-notebook-us-east-1"
120+
us-west-1:
121+
"bucket": "aws-neptune-notebook-us-west-1"
122+
us-west-2:
123+
"bucket": "aws-neptune-notebook-us-west-2"
124+
ap-south-1:
125+
"bucket": "aws-neptune-notebook-ap-south-1"
126+
ap-northeast-2:
127+
"bucket": "aws-neptune-notebook-ap-northeast-2"
128+
ap-southeast-1:
129+
"bucket": "aws-neptune-notebook-ap-southeast-1"
130+
ap-southeast-2:
131+
"bucket": "aws-neptune-notebook-ap-southeast-2"
132+
ap-northeast-1:
133+
"bucket": "aws-neptune-notebook-ap-northeast-1"
134+
ca-central-1:
135+
"bucket": "aws-neptune-notebook-ca-central-1"
136+
eu-central-1:
137+
"bucket": "aws-neptune-notebook-eu-central-1"
138+
eu-west-1:
139+
"bucket": "aws-neptune-notebook-eu-west-1"
140+
eu-west-2:
141+
"bucket": "aws-neptune-notebook-eu-west-2"
142+
eu-west-3:
143+
"bucket": "aws-neptune-notebook-eu-west-3"
144+
eu-north-1:
145+
"bucket": "aws-neptune-notebook-eu-north-1"
146+
sa-east-1:
147+
"bucket": "aws-neptune-notebook-sa-east-1"
148+
af-south-1:
149+
"bucket": "aws-neptune-notebook-af-south-1"
150+
ap-east-1:
151+
"bucket": "aws-neptune-notebook-ap-east-1"
152+
me-south-1:
153+
"bucket": "aws-neptune-notebook-me-south-1"
154+
me-central-1:
155+
"bucket": "aws-neptune-notebook-me-central-1"
156+
ap-south-2:
157+
"bucket": "aws-neptune-notebook-ap-south-2"
158+
il-central-1:
159+
"bucket": "aws-neptune-notebook-il-central-1"
160+
us-gov-east-1:
161+
"bucket": "aws-neptune-notebook-us-gov-east-1"
162+
us-gov-west-1:
163+
"bucket": "aws-neptune-notebook-us-gov-west-1"
164+
110165
Resources:
111166
NeptuneNotebookInstance:
112167
Type: AWS::SageMaker::NotebookInstance
@@ -148,21 +203,27 @@ Resources:
148203
Properties:
149204
OnStart:
150205
- Content:
151-
Fn::Base64: !Sub |
152-
#!/bin/bash
153-
sudo -u ec2-user -i << 'EOF'
154-
echo 'export GRAPH_NOTEBOOK_AUTH_MODE=${NeptuneClusterAuthMode}' >> ~/.bashrc
155-
echo 'export GRAPH_NOTEBOOK_SSL=True' >> ~/.bashrc
156-
echo 'export GRAPH_NOTEBOOK_HOST=${NeptuneClusterEndpoint}' >> ~/.bashrc
157-
echo 'export GRAPH_NOTEBOOK_PORT=${NeptuneClusterPort}' >> ~/.bashrc
158-
echo "export GRAPH_NOTEBOOK_SERVICE=neptune-db" >> ~/.bashrc
159-
echo 'export NEPTUNE_LOAD_FROM_S3_ROLE_ARN=${NeptuneClusterLoadFromS3Arn}' >> ~/.bashrc
160-
echo 'export AWS_REGION=${AWS::Region}' >> ~/.bashrc
161-
aws s3 cp s3://aws-neptune-notebook-${AWS::Region}/graph_notebook.tar.gz /tmp/graph_notebook.tar.gz
162-
rm -rf /tmp/graph_notebook
163-
tar -zxvf /tmp/graph_notebook.tar.gz -C /tmp
164-
/tmp/graph_notebook/install.sh
165-
EOF
206+
Fn::Base64: !Sub
207+
- |+
208+
#!/bin/bash
209+
sudo -u ec2-user -i << 'EOF'
210+
echo 'export GRAPH_NOTEBOOK_AUTH_MODE=${NeptuneClusterAuthMode}' >> ~/.bashrc
211+
echo 'export GRAPH_NOTEBOOK_SSL=True' >> ~/.bashrc
212+
echo 'export GRAPH_NOTEBOOK_HOST=${NeptuneClusterEndpoint}' >> ~/.bashrc
213+
echo 'export GRAPH_NOTEBOOK_PORT=${NeptuneClusterPort}' >> ~/.bashrc
214+
echo "export GRAPH_NOTEBOOK_SERVICE=neptune-db" >> ~/.bashrc
215+
echo 'export NEPTUNE_LOAD_FROM_S3_ROLE_ARN=${NeptuneClusterLoadFromS3Arn}' >> ~/.bashrc
216+
echo 'export AWS_REGION=${AWS::Region}' >> ~/.bashrc
217+
aws s3 cp s3://${S3Bucket}/graph_notebook.tar.gz /tmp/graph_notebook.tar.gz
218+
rm -rf /tmp/graph_notebook
219+
tar -zxvf /tmp/graph_notebook.tar.gz -C /tmp
220+
/tmp/graph_notebook/install.sh
221+
EOF
222+
- S3Bucket:
223+
Fn::FindInMap:
224+
- RegionMap
225+
- Ref: AWS::Region
226+
- bucket
166227

167228
SageMakerNotebookAutoRole:
168229
Type: AWS::IAM::Role
@@ -185,8 +246,20 @@ Resources:
185246
- s3:GetObject
186247
- s3:ListBucket
187248
Resource:
188-
- Fn::Sub: "arn:${AWS::Partition}:s3:::aws-neptune-notebook-${AWS::Region}"
189-
- Fn::Sub: "arn:${AWS::Partition}:s3:::aws-neptune-notebook-${AWS::Region}/*"
249+
- Fn::Sub:
250+
- "arn:${AWS::Partition}:s3:::${S3Bucket}"
251+
- S3Bucket:
252+
Fn::FindInMap:
253+
- RegionMap
254+
- Ref: AWS::Region
255+
- bucket
256+
- Fn::Sub:
257+
- "arn:${AWS::Partition}:s3:::${S3Bucket}/*"
258+
- S3Bucket:
259+
Fn::FindInMap:
260+
- RegionMap
261+
- Ref: AWS::Region
262+
- bucket
190263
- Effect: Allow
191264
Action: neptune-db:connect
192265
Resource:

0 commit comments

Comments
 (0)