From 40b58573a05cc264feca3e1a67835286e507c4f4 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 2 Jul 2019 11:08:18 +1200 Subject: [PATCH 1/2] Use env constants No longer using _ss_env in the 4.x version --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 481c20e..79ad700 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ Add these custom repositories to your composer.json ## Sessions with DynamoDB -If you wish to store sessions in DynamoDB, set the following environment variables in your `_ss_environment.php` file: +If you wish to store sessions in DynamoDB, set the required environment variables in `.env`: // the name of the DynamoDB table to store sessions in - define('AWS_DYNAMODB_SESSION_TABLE', 'mysession'); + AWS_DYNAMODB_SESSION_TABLE=mysession // the region that the DynamoDB table will live in (in this example here it uses Sydney) - define('AWS_REGION_NAME', 'ap-southeast-2'); + AWS_REGION_NAME=ap-southeast-2 Once these are in place, this module will configure DynamoDB and register that as the session handler. @@ -35,8 +35,8 @@ in EC2 instances, as credentials are automatically handled by the IAM role insid // the AWS access key and secret. This is optional if you've configured an instance with an IAM role // http://docs.aws.amazon.com/aws-sdk-php/guide/latest/credentials.html#caching-iam-role-credentials - define('AWS_ACCESS_KEY', ''); - define('AWS_SECRET_KEY', ''); + AWS_ACCESS_KEY=my-access-key + AWS_SECRET_KEY=my-secret ## Garbage collecting sessions From 5af43d499de35b820b0e4cef3de9829425753a41 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 2 Jul 2019 11:08:25 +1200 Subject: [PATCH 2/2] DOCS Tips for local dev --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index 79ad700..324d7e4 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,51 @@ For example, in your `_ss_environment.php` file, set garbage collection after 1 See https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/dynamodb-session-handler.html for more information. +## Local Testing + +You can simulate DynamoDB locally for easier development through [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SettingUp.html). + +Set environment constants. Note that actual access keys and regions are ignored, +they just need to be defined. + +``` +AWS_DYNAMODB_SESSION_TABLE=mysession +AWS_ACCESS_KEY=my-access-key +AWS_SECRET_KEY=my-secret +AWS_DYNAMODB_ENDPOINT=http://localhost:8000 +AWS_REGION_NAME=us-east-1 +``` + +Download [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SettingUp.html) +and start it - it'll be available under `http://localhost:8000`. + +Now use the [AWS CLI Tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) +to interact with your local DynamoDB. + +Create table: + +``` +aws dynamodb create-table --table-name mysession --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 --endpoint-url http://localhost:8000 +``` + +List tables: + +``` +aws dynamodb list-tables --endpoint-url http://localhost:8000 +``` + +List all sessions: + +``` +aws dynamodb scan --table-name mysession --endpoint-url http://localhost:8000 +``` + +Delete all sessions (use create table to reset afterwards): + +``` +aws dynamodb delete-table --table-name mysession --endpoint-url http://localhost:8000 +``` + ## Contribute Do you want to contribute? Great, please see the [CONTRIBUTING.md](CONTRIBUTING.md)