Skip to content

Commit b93930d

Browse files
committed
cqlsh-expansion default entry point
updated default entry point to be the expansion.
1 parent ef31ea9 commit b93930d

File tree

4 files changed

+105
-96
lines changed

4 files changed

+105
-96
lines changed

Dockerfile renamed to Docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ COPY cqlsh-expansion/config/cqlshrc_template $CQLSHRC_HOME/cqlshrc
5858

5959
ENV PATH="${PATH}:$AWS_KEYSPACES_WORKING_DIR/bin:$CASSANDRA_HOME/bin"
6060

61-
ENTRYPOINT ["cqlsh"]
61+
ENTRYPOINT ["cqlsh-expansion"]

Docker/README.md

Whitespace-only changes.

README.md

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# Amazon Keyspaces (for Apache Cassandra) developer toolkit
22

3-
This repository provides a Docker image for common tooling for Amazon Keyspaces. Keyspaces for functional testing, light operations, and data migration.
4-
5-
The toolkit is optimized for Amazon Keyspaces, but will also work with Apache Cassandra clusters.
3+
This repository provides common tooling for Amazon Keyspaces for functional testing, light operations, and data migration. The tooling is packaged as a Docker image or python package to simplify setup and configuration. The toolkit is optimized for Amazon Keyspaces, but will also work with Apache Cassandra clusters.
64

75
## Amazon Keyspaces (for Apache Cassandra)
86
[Amazon Keyspaces](https://aws.amazon.com/keyspaces/) is a scalable, highly available, and managed Apache Cassandra–compatible database service. Amazon Keyspaces is serverless, so you pay for only the resources you use and the service can automatically scale tables up and down in response to application traffic.
97

108
## What's included
119
This container extends from [awscli container](https://aws.amazon.com/blogs/developer/aws-cli-v2-docker-image/) and includes the following Cassandra components:
1210
* 3.11.6 Apache Cassandra distribution of CQLSH
11+
* cqlsh expansion that integrates sigv4 authentication
1312
* Amazon Web Services pem file for SSL connectivity
1413
* CQLSHRC file with best practices
1514
* Helpers/examples to perform to common task
1615
* AWS CLI. Official Documentation [See How to use the AWSCLI Container](https://aws.amazon.com/blogs/developer/aws-cli-v2-docker-image/)
17-
* optional cqlsh expansion that integrates sigv4 authentication
16+
1817

1918
### Architecture
2019
![Figure 1-1](content/static/keyspaces-toolkit-architecture.png "Architecture")
@@ -26,30 +25,49 @@ This container extends from [awscli container](https://aws.amazon.com/blogs/deve
2625
* Extends from AWS CLI Container Image and can be accessed via overriding the [entrypoint](https://docs.docker.com/engine/reference/builder/#entrypoint) parameter
2726

2827
# TLDR;
29-
The following steps to connect to Amazon Keyspaces using the Toolkit. Clone. Build Image. Connect to Keyspaces and Go!
28+
The following steps to connect to Amazon Keyspaces using the Toolkit.
3029

30+
## Docker
31+
Clone the github repoistory, Build Docker Image, Connect to Keyspaces, and Go!
3132
```sh
32-
docker build --tag amazon/keyspaces-toolkit --build-arg CLI_VERSION=latest https://github.com/aws-samples/amazon-keyspaces-toolkit.git
33+
docker build --tag amazon/amazon-keyspaces-toolkit --build-arg CLI_VERSION=latest https://github.com/aws-samples/amazon-keyspaces-toolkit.git
3334

34-
docker run --rm -ti amazon/keyspaces-toolkit cassandra.us-east-1.amazonaws.com 9142 -u "SERVICEUSERNAME" -p "SERVICEPASSWORD" --ssl
35+
docker run --rm -ti amazon/amazon-keyspaces-toolkit cassandra.us-east-1.amazonaws.com 9142 -u "SERVICEUSERNAME" -p "SERVICEPASSWORD" --ssl
36+
37+
```
38+
39+
## Python
40+
```sh
41+
pip install --user cqlsh-expansion
42+
43+
cqlsh-expansion.init
44+
45+
cqlsh cassandra.us-east-1.amazonaws.com 9142 --ssl -u mike-user-99 -p user-pass-01
3546

3647
```
3748

3849
# Using Sigv4 Authentication with cqlsh
39-
The toolkit contains a version of cqlsh that extends Authentication functionality to leverage the [Sigv4 athentication plugin for the Python Cassandra driver](https://github.com/aws/aws-sigv4-auth-cassandra-python-driver-plugin). This plugin enables IAM users, roles, and federated identities to add authentication information to Amazon Keyspaces (for Apache Cassandra) API requests using the AWS Signature Version 4 Process (SigV4). You can leverage this functionality by passing "cqlsh-expansion" to the ```--entrypoint``` docker run parameter, and the ```--auth-provider "SigV4AuthProvider"``` flag to the cqlsh-expansion process. You can use the docker container host's credentials by mounting the AWS CLI configuration directory to the container using the mount command ```-v```. If your AWS configuration is stored in ~/.aws then the Docker mount command would be `-v ~/.aws:/root/.aws`.
50+
The toolkit contains a version of cqlsh that extends Authentication functionality to leverage the [Sigv4 athentication plugin for the Python Cassandra driver](https://github.com/aws/aws-sigv4-auth-cassandra-python-driver-plugin). This plugin enables IAM users, roles, and federated identities to add authentication information to Amazon Keyspaces (for Apache Cassandra) API requests using the AWS Signature Version 4 Process (SigV4). You can leverage this functionality by passing the ```--auth-provider "SigV4AuthProvider"``` flag to the cqlsh-expansion process. You can use the docker container host's credentials by mounting the AWS CLI configuration directory to the container using the mount command ```-v```. If your AWS configuration is stored in ~/.aws then the Docker mount command would be `-v ~/.aws:/root/.aws`.
4051

52+
## Docker
4153
```sh
42-
docker build --tag amazon/keyspaces-toolkit --build-arg CLI_VERSION=latest https://github.com/aws-samples/amazon-keyspaces-toolkit.git
54+
docker build --tag amazon/amazon-keyspaces-toolkit --build-arg CLI_VERSION=latest https://github.com/aws-samples/amazon-keyspaces-toolkit.git
4355

44-
docker run -ti --rm -v ~/.aws:/root/.aws --entrypoint cqlsh-expansion amazon/keyspaces-toolkit cassandra.us-east-1.amazonaws.com --ssl --auth-provider "SigV4AuthProvider"
56+
docker run -ti --rm -v ~/.aws:/root/.aws amazon/amazon-keyspaces-toolkit cassandra.us-east-1.amazonaws.com --ssl --auth-provider "SigV4AuthProvider"
4557
```
58+
## Python
59+
```sh
60+
pip install --user cqlsh-expansion
61+
62+
cqlsh-expansion.init
4663

64+
cqlsh-expansion cassandra.us-east-1.amazonaws.com 9142 --ssl --auth-provider "SigV4AuthProvider"
65+
66+
```
4767
# Prerequisites
4868

4969
### Generate Service Specific Credentials
50-
Service-specific credentials enable IAM users to access a specific AWS service. The credentials cannot be used to access other AWS services. They are associated with a specific IAM user and cannot be used by other IAM users.
51-
52-
* See official documentation for IAM user [Generated service-specific credentials](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.credentials.html) for Amazon Keyspaces
70+
If you are using the Service-specific credentials for IAM users to access Amazon Keyspaces. See official documentation for IAM user [Generated service-specific credentials](https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.credentials.html) for Amazon Keyspaces
5371

5472

5573
### Setup Docker
@@ -69,7 +87,7 @@ The following section will provide examples of CQLSH usage with Apache Cassandra
6987
The following command will clone this repository and pull down submodules
7088

7189
```sh
72-
git clone --recurse-submodules https://github.com/aws-samples/amazon-keyspaces-toolkit
90+
git clone https://github.com/aws-samples/amazon-keyspaces-toolkit
7391
```
7492

7593
### Use an alias
@@ -89,11 +107,11 @@ CQLSH scripts
89107
```sh
90108
#!/bin/bash
91109

92-
alias cqlsh='touch ${HOME}/.cassandra/cqlsh_history && docker run --rm -ti -v "$(pwd)":/source -v "${HOME}/.cassandra/cqlsh_history":/root/.cassandra/cqlsh_history amazon/keyspaces-toolkit'
110+
alias cqlsh='touch ${HOME}/.cassandra/cqlsh_history && docker run --rm -ti -v "$(pwd)":/source -v "${HOME}/.cassandra/cqlsh_history":/root/.cassandra/cqlsh_history amazon/amazon-keyspaces-toolkit'
93111

94112
```
95113

96-
You can now connect to Amazon Keyspaces using CQLSH command and pass in the host port and user name and password.
114+
You can now connect to Amazon Keyspaces using CQLSH alias and pass in the host port and user name and password.
97115

98116
```sh
99117
cqlsh cassandra.us-east-1.amazonaws.com 9142 --ssl \
@@ -150,7 +168,7 @@ Changing the entry point to `aws` will allow you to access the AWS CLI. Mounting
150168
docker run --rm -ti \
151169
-v ~/.aws:/root/.aws \
152170
--entrypoint aws \
153-
amazon/keyspaces-toolkit
171+
amazon/amazon-keyspaces-toolkit
154172
configure list-profiles
155173
```
156174

@@ -185,15 +203,15 @@ _*Example: open cqlsh shell*_
185203
docker run --rm -ti \
186204
-v ~/.aws:/root/.aws \
187205
--entrypoint aws-sm-cqlsh.sh \
188-
amazon/keyspaces-toolkit keyspaces-credentials \
206+
amazon/amazon-keyspaces-toolkit keyspaces-credentials \
189207
cassandra.us-east-1.amazonaws.com 9142 --ssl
190208
```
191209
_*Example: execute statement*_
192210
```sh
193211
docker run --rm -ti \
194212
-v ~/.aws:/root/.aws \
195213
--entrypoint aws-sm-cqlsh.sh \
196-
amazon/keyspaces-toolkit keyspaces-credentials \
214+
amazon/amazon-keyspaces-toolkit keyspaces-credentials \
197215
cassandra.us-east-1.amazonaws.com 9142 --ssl \
198216
--execute "CREATE TABLE aws.workshop(
199217
id text,
@@ -205,7 +223,7 @@ docker run --rm -ti \
205223
```
206224

207225
## Exponential Backoff Wrapper
208-
Keyspace and table creation are Asynchronous in Amazon Keyspaces. This asynchronous functionality is different than Apache Cassandra where table creation is synchronous. We have been told by customers that some existing scripts require synchronous behavior when creating a table. A common solution is to add an exponential backoff describe statement to notify users when the table is created. This container contains an exponential backoff helper that will attempt multiple times until the CQL statement succeeds. Other options include building a CloudFormation template.
226+
Keyspace and table creation are Asynchronous in Amazon Keyspaces. This asynchronous functionality is different than Apache Cassandra where table creation is synchronous. We have been told by customers that some existing scripts require synchronous behavior when creating a table. A common solution is to add an exponential backoff describe statement to notify users when the table is created. This container contains an exponential backoff helper that will attempt multiple times until the CQL statement succeeds.
209227

210228
`Parameters`
211229
* $1 maximum time for program to run in seconds
@@ -216,7 +234,7 @@ Keyspace and table creation are Asynchronous in Amazon Keyspaces. This asynchron
216234
#!/bin/bash
217235

218236
#create a table
219-
docker run -ti --name createtablec amazon/keyspaces-toolkit \
237+
docker run -ti --name createtablec amazon/amazon-keyspaces-toolkit \
220238
cassandra.us-east-1.amazonaws.com 9142 \
221239
-u "SERVICEUSERNAME" -p "SERVICEPASSWORD" --ssl \
222240
--execute "CREATE TABLE aws.workshop_backofftest(
@@ -235,7 +253,7 @@ docker rm createtablec
235253

236254
#exponential backoff describe
237255
#run for 30 seconds or 120 attempts which ever comes first
238-
docker run --rm -ti --entrypoint aws-cqlsh-expo-backoff.sh amazon/keyspaces-toolkit \
256+
docker run --rm -ti --entrypoint aws-cqlsh-expo-backoff.sh amazon/amazon-keyspaces-toolkit \
239257
30 120 \
240258
cassandra.us-east-1.amazonaws.com 9142 \
241259
--ssl -u "SERVICEUSERNAME" -p "SERVICEPASSWORD" \
@@ -251,7 +269,7 @@ docker run --rm -ti --entrypoint aws-cqlsh-expo-backoff.sh amazon/keyspaces-tool
251269
$> docker logs CONTAINERID
252270
253271
#Remove Image
254-
$> docker rmi amazon/keyspaces-toolkit
272+
$> docker rmi amazon/amazon-keyspaces-toolkit
255273
256274
#exit code
257275
docker inspect createtablec --format='{{.State.ExitCode}}'

0 commit comments

Comments
 (0)