Skip to content

Commit 8bdf170

Browse files
committed
Introducing SageMaker connection examples using Sig4V and server-generated credentials.
Grammar/style changes to Readme and notebook text.
1 parent 851a6c0 commit 8bdf170

File tree

4 files changed

+74
-68
lines changed

4 files changed

+74
-68
lines changed

SageMaker/connection-service-specific-credentials /README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,54 @@
33
## Connecting to Amazon Keyspaces from SageMaker Notebook with Python
44

55

6-
This code shows how to connect to Amazon Keyspaces from SageMaker using an [service-specific credentials](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.credentials.html) for an existing AWS Identity and Access Management (IAM) user.
6+
This code shows how to connect to Amazon Keyspaces from SageMaker using [service-specific credentials](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.credentials.html).
77

8-
Service-specific credentials aren’t the only way to authenticate and authorize access to Amazon Keyspaces resources. We recommend using the AWS authentication plugin for Cassandra drivers.
8+
Service-specific credentials aren’t the only way to authenticate and authorize access to Amazon Keyspaces resources. We recommend using AWS authentication plugin for Cassandra drivers .
99

10-
The following code is an example of a service-specific credential .
1110

12-
```
13-
"ServiceSpecificCredential": {
14-
"CreateDate": "2019-10-09T16:12:04Z",
15-
"ServiceName": "cassandra.amazonaws.com",
16-
"ServiceUserName": "keyspace-user1-at-11122223333",
17-
"ServicePassword": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
18-
"ServiceSpecificCredentialId": "ACCAYFI33SINPGJEBYESF",
19-
"UserName": " keyspace-user1",
20-
"Status": "Active"
21-
}
22-
}
23-
```
11+
### Prerequisites<a name="Prerequisites"></a></a>
12+
The Notebook execution role must include permissions to access Amazon Keyspaces and [Secret Manager](https://aws.amazon.com/secrets-manager/).
2413

14+
* To access Amazon Keyspaces database - use AmazonKeyspacesReadOnlyAccess or AmazonKeyspacesFullAccess managed policies. Use the _least privileged approach_ for your production application.
15+
See more at
16+
[AWS Identity and Access Management for Amazon Keyspaces](https://docs.aws.amazon.com/keyspaces/latest/devguide/security-iam.html).
2517

18+
* To use AWS Secret Manager, the Notebooks execution role must include [SecretsManagerReadWrite](https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_available-policies.html) managed policy.
19+
20+
21+
22+
### Security Configuration
23+
24+
1. Generate [Keyspaces Service-Specific Credentials](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.credentials.html)
2625

27-
### Prerequisites<a name="Prerequisites"></a></a>
28-
This notebook was tested with conda_python3 kernel and should work with Python 3.x.
2926

30-
The Notebook execution role must include permissions to access Amazon Keyspaces and Assume the role.
31-
32-
* To access Amazon Keyspaces database - can use AmazonKeyspacesReadOnlyAccess or AmazonKeyspacesFullAccess managed policies. Use the least privilege approach for your production application.
33-
[AWS Identity and Access Management for Amazon Keyspaces](https://docs.aws.amazon.com/keyspaces/latest/devguide/security-iam.html)
34-
35-
* To assume the role you need to have [sts:AssumeRole action](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) permissions
36-
```
37-
{
38-
"Version": "2012-10-17",
39-
"Statement": [
40-
{
41-
"Action": [
42-
"sts:AssumeRole"
43-
],
44-
"Effect": "Allow",
45-
"Resource": "*"
27+
Example of a service-specific credential
28+
29+
```
30+
"ServiceSpecificCredential": {
31+
"CreateDate": "2019-10-09T16:12:04Z",
32+
"ServiceName": "cassandra.amazonaws.com",
33+
"ServiceUserName": "keyspace-user1-at-11122223333",
34+
"ServicePassword": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
35+
"ServiceSpecificCredentialId": "ACCAYFI33SINPGJEBYESF",
36+
"UserName": " keyspace-user1",
37+
"Status": "Active"
38+
}
4639
}
47-
]
48-
}
49-
```
40+
```
41+
42+
2. Store ServiceUserName and ServicePassword in the SecretManager. As a best practice, we don't want to store credentials as a plain text in the SageMaker Notebooks.
43+
44+
In this example I'm using
45+
_Keyspaces_Server_Generated_credential_ as a Secret Name and _keyspaces_generated_id_ and _keyspaces_generated_pw_ fields to store Keyspaces ID and password.
46+
47+
48+
5049

5150
#### Note:
52-
Amazon Keyspaces is available in the following [AWS Regions](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.endpoints.html)
51+
Amazon Keyspaces is available in the following [AWS Regions](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.endpoints.html).
5352

53+
This notebook was tested with conda_python3 kernel and should work with Python 3.x.
5454

5555
### Running the sample
5656
* Import Notebook into SageMaker

SageMaker/connection-service-specific-credentials /SageMaker_Keyspaces_with_server_credentials.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "9d63b0ce",
5+
"id": "efe02727",
66
"metadata": {},
77
"source": [
88
"## Connecting to Amazon Keyspaces using server-side credentials \n",
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"cell_type": "markdown",
15-
"id": "eb60e0cd",
15+
"id": "68d038c1",
1616
"metadata": {},
1717
"source": [
1818
"Before we start we need to generate the Keyspaces credential and use SecretManager to securly store credentials. \n",
@@ -45,7 +45,7 @@
4545
{
4646
"cell_type": "code",
4747
"execution_count": null,
48-
"id": "6984b585",
48+
"id": "d4fd77c1",
4949
"metadata": {},
5050
"outputs": [],
5151
"source": [
@@ -60,7 +60,7 @@
6060
{
6161
"cell_type": "code",
6262
"execution_count": null,
63-
"id": "1947cbf2",
63+
"id": "9e06a3a6",
6464
"metadata": {},
6565
"outputs": [],
6666
"source": [
@@ -71,7 +71,7 @@
7171
{
7272
"cell_type": "code",
7373
"execution_count": null,
74-
"id": "b7850692",
74+
"id": "572c391a",
7575
"metadata": {},
7676
"outputs": [],
7777
"source": [
@@ -82,7 +82,7 @@
8282
{
8383
"cell_type": "code",
8484
"execution_count": null,
85-
"id": "9d6d8906",
85+
"id": "df0a72d8",
8686
"metadata": {},
8787
"outputs": [],
8888
"source": [
@@ -125,7 +125,7 @@
125125
{
126126
"cell_type": "code",
127127
"execution_count": null,
128-
"id": "469b854b",
128+
"id": "e4425550",
129129
"metadata": {},
130130
"outputs": [],
131131
"source": [
@@ -135,7 +135,7 @@
135135
{
136136
"cell_type": "code",
137137
"execution_count": null,
138-
"id": "38a8ea09",
138+
"id": "03fa7f66",
139139
"metadata": {},
140140
"outputs": [],
141141
"source": [
@@ -145,7 +145,7 @@
145145
{
146146
"cell_type": "code",
147147
"execution_count": null,
148-
"id": "ed4076e2",
148+
"id": "75c23dba",
149149
"metadata": {},
150150
"outputs": [],
151151
"source": [
@@ -158,7 +158,7 @@
158158
{
159159
"cell_type": "code",
160160
"execution_count": null,
161-
"id": "b2bf80c9",
161+
"id": "4c5c27c0",
162162
"metadata": {},
163163
"outputs": [],
164164
"source": [
@@ -172,7 +172,7 @@
172172
{
173173
"cell_type": "code",
174174
"execution_count": null,
175-
"id": "75334b15",
175+
"id": "a3abaf72",
176176
"metadata": {},
177177
"outputs": [],
178178
"source": []

SageMaker/connection-sigv4/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
This code shows how to connect to Amazon Keyspaces from SageMaker using an authentication plugin for temporary credentials. This plugin enables IAM users, roles, and federated identities to add authentication information to Amazon Keyspaces API requests using the AWS Signature Version 4 process (SigV4).
44

5-
In this example we do NOT need to generate Keyspaces service-specific credentials.
5+
In this example, we do NOT need to generate Keyspaces service-specific credentials.
6+
67

78

89
### Prerequisites
9-
This notebook was tested with conda_python3 kernel and should work with Python 3.x.
1010

1111
The Notebook execution role must include permissions to access Amazon Keyspaces and Assume the role.
1212

13-
* To access Amazon Keyspaces database - can use AmazonKeyspacesReadOnlyAccess or AmazonKeyspacesFullAccess managed policies. Use the least privilege approach for your production application.
14-
[AWS Identity and Access Management for Amazon Keyspaces](https://docs.aws.amazon.com/keyspaces/latest/devguide/security-iam.html)
13+
* To access Amazon Keyspaces database - use AmazonKeyspacesReadOnlyAccess or AmazonKeyspacesFullAccess managed policies. Use the _least privileged approach_ for your production application.
14+
See more at
15+
[AWS Identity and Access Management for Amazon Keyspaces](https://docs.aws.amazon.com/keyspaces/latest/devguide/security-iam.html).
1516

1617
* To assume the role you need to have [sts:AssumeRole action](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) permissions
1718
```
@@ -32,6 +33,9 @@ The Notebook execution role must include permissions to access Amazon Keyspaces
3233
#### Note:
3334
Amazon Keyspaces is available in the following [AWS Regions](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.endpoints.html)
3435
36+
This notebook was tested with conda_python3 kernel and should work with Python 3.x.
37+
38+
3539
3640
### Running the sample
3741
* Import Notebook into SageMaker

SageMaker/connection-sigv4/SageMaker_Keyspaces_with_ sigv4.ipynb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "b455f1e8",
5+
"id": "d0f1440d",
66
"metadata": {},
77
"source": [
88
"## Connecting to Amazon Keyspaces using SigV4 authentication plugin for temporary credentials. \n",
9-
"##### This plugin enables IAM users, roles, and federated identities to add authentication information to Amazon Keyspaces API requests using the AWS Signature Version 4 process (SigV4).\n",
109
"\n",
11-
"More info about [SigV4](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) \n"
10+
"This plugin enables IAM users, roles, and federated identities to add authentication information to Amazon Keyspaces API requests using the [AWS Signature Version 4 process (SigV4)](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) .\n",
11+
"\n",
12+
"In this example, we do NOT need to generate Keyspaces service-specific credentials."
1213
]
1314
},
1415
{
1516
"cell_type": "markdown",
16-
"id": "9c744358",
17+
"id": "9cdcdeca",
1718
"metadata": {},
1819
"source": [
1920
"### Requrements \n",
2021
"\n",
2122
"The Notebook execution role must include permissions to access Amazon Keyspaces and Assume the role. \n",
2223
"\n",
24+
"* To access Amazon Keyspaces database - use AmazonKeyspacesReadOnlyAccess or AmazonKeyspacesFullAccess managed policies. Use the _least privileged approach_ for your production application. \n",
25+
"See more at\n",
26+
"[AWS Identity and Access Management for Amazon Keyspaces](https://docs.aws.amazon.com/keyspaces/latest/devguide/security-iam.html).\n",
2327
"\n",
24-
"* To access Amazon Keyspaces database - can use AmazonKeyspacesReadOnlyAccess or AmazonKeyspacesFullAccess managed policies. See [AWS Identity and Access Management for Amazon Keyspaces](https://docs.aws.amazon.com/keyspaces/latest/devguide/security-iam.html). Use the least privilege approach for your production application.\n",
25-
"\n",
26-
"* To assume the role you need to have [sts:AssumeRole action](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) permissions\n",
28+
"* To assume the role, you need to have [sts:AssumeRole action](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) permissions.\n",
2729
" ```\n",
2830
" {\n",
2931
" \"Version\": \"2012-10-17\", \n",
@@ -40,15 +42,15 @@
4042
" ```\n",
4143
"\n",
4244
"#### Note:\n",
43-
"Amazon Keyspaces is available in the following [AWS Regions](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.endpoints.html)\n",
45+
"Amazon Keyspaces is available in the following [AWS Regions](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.endpoints.html).\n",
4446
"\n",
4547
"This notebook was tested with conda_python3 kernel and should work with Python 3.x."
4648
]
4749
},
4850
{
4951
"cell_type": "code",
5052
"execution_count": null,
51-
"id": "8d8f6586",
53+
"id": "b34480df",
5254
"metadata": {},
5355
"outputs": [],
5456
"source": [
@@ -59,7 +61,7 @@
5961
{
6062
"cell_type": "code",
6163
"execution_count": null,
62-
"id": "38b1cef1",
64+
"id": "e8b700d9",
6365
"metadata": {},
6466
"outputs": [],
6567
"source": [
@@ -70,7 +72,7 @@
7072
{
7173
"cell_type": "code",
7274
"execution_count": null,
73-
"id": "75c6b109",
75+
"id": "d6b40a2a",
7476
"metadata": {},
7577
"outputs": [],
7678
"source": [
@@ -85,7 +87,7 @@
8587
{
8688
"cell_type": "code",
8789
"execution_count": null,
88-
"id": "97968cc2",
90+
"id": "6e690e59",
8991
"metadata": {},
9092
"outputs": [],
9193
"source": [
@@ -106,7 +108,7 @@
106108
{
107109
"cell_type": "code",
108110
"execution_count": null,
109-
"id": "7989f29a",
111+
"id": "a88c43df",
110112
"metadata": {},
111113
"outputs": [],
112114
"source": [
@@ -145,7 +147,7 @@
145147
{
146148
"cell_type": "code",
147149
"execution_count": null,
148-
"id": "c44764ae",
150+
"id": "4933806d",
149151
"metadata": {},
150152
"outputs": [],
151153
"source": [
@@ -158,7 +160,7 @@
158160
{
159161
"cell_type": "code",
160162
"execution_count": null,
161-
"id": "38e7d513",
163+
"id": "a81cb54d",
162164
"metadata": {},
163165
"outputs": [],
164166
"source": [
@@ -176,7 +178,7 @@
176178
},
177179
{
178180
"cell_type": "markdown",
179-
"id": "a9c695e4",
181+
"id": "320eac56",
180182
"metadata": {},
181183
"source": [
182184
"## The end."

0 commit comments

Comments
 (0)