From 214071707b683b64446c247afc09364f7dfb084f Mon Sep 17 00:00:00 2001 From: Peter Chamberlin Date: Tue, 4 Oct 2016 11:12:55 +0100 Subject: [PATCH 1/8] Updated README based on my experience getting things running --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc29d8fb1..467b50414 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ Application for the notification api. Read and write notifications/status queue. Get and update notification status. +## Before you start + +To run the API you will need appropriate AWS credentials. You should receive these from whoever administrates your AWS account. Make sure you've got both an `access key id` and a `secret access key`. + ## Setting Up ``` @@ -15,7 +19,7 @@ mkvirtualenv -p /usr/local/bin/python3 notifications-api Creating the environment.sh file. Replace [unique-to-environment] with your something unique to the environment. Your AWS credentials should be set up for notify-tools (the development/CI AWS account). -Create a local environment.sh file containing the following: +Create a local environment.sh file containing the following, updating the AWS key entries with your own values: ``` echo " @@ -32,6 +36,9 @@ export LOADTESTING_API_KEY="FIRETEXT_SIMULATION_KEY" export FIRETEXT_API_KEY="FIRETEXT_ACTUAL_KEY" export STATSD_PREFIX="FAKE_PREFIX" export NOTIFICATION_QUEUE_PREFIX="PREFIX-TO-IDENTIFY-SQS-QUEUE" +export AWS_REGION='eu-west-1' +export AWS_ACCESS_KEY_ID= +export AWS_SECRET_ACCESS_KEY= "> environment.sh ``` @@ -39,11 +46,15 @@ NOTE: The SECRET_KEY and DANGEROUS_SALT should match those in the [notifications NOTE: Also note the unique prefix for the queue names. This prevents clashing with others queues in shared amazon environment and using a prefix enables filtering by queue name in the SQS interface. -Install Postgresql +Install [Postgres.app](http://postgresapp.com/). You will need admin on your machine to do this. + +Assuming you downloaded the ZIP file to `~/Downloads` and expanded it there, you should be able to run the following to install the app: -```shell - brew install postgres ``` +sudo -b ~/Downloads/Postgres.app/Contents/MacOS/Postgres +``` + +This will execute the app as a background process (so you can close the terminal window and it won't stop). The install process should offer to move the app to `Applications`. ## To run the application From 1539a527e6f5a816c868f7adc030d8f0104be6a7 Mon Sep 17 00:00:00 2001 From: Peter Chamberlin Date: Tue, 4 Oct 2016 11:13:43 +0100 Subject: [PATCH 2/8] Updated bootstrap to copy `version.py.dist` as required --- scripts/bootstrap.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 5c924e59b..a406cdc2e 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -25,6 +25,10 @@ if [ ! $VIRTUAL_ENV ]; then . ./venv/bin/activate fi +# if there isn't a version file we should copy the .dist one +if [ ! -f ./app/version.py ]; then + cp ./app/version.py.dist ./app/version.py +fi # Install Python development dependencies pip3 install -r requirements_for_test.txt From 26325ff5e7ff7d8db0dd3c2a56c65c03ebb17e5b Mon Sep 17 00:00:00 2001 From: Peter Chamberlin Date: Tue, 4 Oct 2016 11:18:43 +0100 Subject: [PATCH 3/8] Corrected repo name/link for func tests --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 467b50414..74eb0ab78 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ make test ``` That will run pep8 for code analysis and our unit test suite. If you wish to run our functional tests, instructions can be found in the -[notifications-functional-test](https://github.com/alphagov/notifications-functional-test) repository. +[notifications-functional-tests](https://github.com/alphagov/notifications-functional-tests) repository. From b0d0a5627d0ce2a89d0da28144b46892665dc318 Mon Sep 17 00:00:00 2001 From: Peter Chamberlin Date: Tue, 4 Oct 2016 12:03:07 +0100 Subject: [PATCH 4/8] Use make to generate version file --- scripts/bootstrap.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index a406cdc2e..15c1d8ef0 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -25,10 +25,8 @@ if [ ! $VIRTUAL_ENV ]; then . ./venv/bin/activate fi -# if there isn't a version file we should copy the .dist one -if [ ! -f ./app/version.py ]; then - cp ./app/version.py.dist ./app/version.py -fi +# we need the version file to exist otherwise the app will blow up +make generate-version-file # Install Python development dependencies pip3 install -r requirements_for_test.txt From df2d081c1469fc1cb9b72f2596ba10c30554bb41 Mon Sep 17 00:00:00 2001 From: Peter Chamberlin Date: Tue, 4 Oct 2016 12:05:46 +0100 Subject: [PATCH 5/8] Removed extraneous back ticks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 74eb0ab78..f7d46094a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Get and update notification status. ## Before you start -To run the API you will need appropriate AWS credentials. You should receive these from whoever administrates your AWS account. Make sure you've got both an `access key id` and a `secret access key`. +To run the API you will need appropriate AWS credentials. You should receive these from whoever administrates your AWS account. Make sure you've got both an access key id and a secret access key. ## Setting Up From 555163aa48c4e49e5cf707e713318e9fefa3766b Mon Sep 17 00:00:00 2001 From: Pete Date: Tue, 4 Oct 2016 12:30:37 +0100 Subject: [PATCH 6/8] AWS region should probably be user-defined too --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f7d46094a..5a2d8d49f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ export LOADTESTING_API_KEY="FIRETEXT_SIMULATION_KEY" export FIRETEXT_API_KEY="FIRETEXT_ACTUAL_KEY" export STATSD_PREFIX="FAKE_PREFIX" export NOTIFICATION_QUEUE_PREFIX="PREFIX-TO-IDENTIFY-SQS-QUEUE" -export AWS_REGION='eu-west-1' +export AWS_REGION= export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= "> environment.sh From f8db1a97311915fba0c41733e35ad33dc82537b7 Mon Sep 17 00:00:00 2001 From: Pete Date: Tue, 4 Oct 2016 12:30:55 +0100 Subject: [PATCH 7/8] Spelling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a2d8d49f..a5bb2c111 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ export LOADTESTING_API_KEY="FIRETEXT_SIMULATION_KEY" export FIRETEXT_API_KEY="FIRETEXT_ACTUAL_KEY" export STATSD_PREFIX="FAKE_PREFIX" export NOTIFICATION_QUEUE_PREFIX="PREFIX-TO-IDENTIFY-SQS-QUEUE" -export AWS_REGION= +export AWS_REGION= export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= "> environment.sh From b3c213406d9dfe63d408e38674458e8c4988c81f Mon Sep 17 00:00:00 2001 From: Peter Chamberlin Date: Tue, 4 Oct 2016 15:09:58 +0100 Subject: [PATCH 8/8] Changes after review, and further thinking... --- README.md | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index a5bb2c111..28dc6e38f 100644 --- a/README.md +++ b/README.md @@ -7,55 +7,54 @@ Application for the notification api. Read and write notifications/status queue. Get and update notification status. -## Before you start +## Setting Up + +### AWS credentials To run the API you will need appropriate AWS credentials. You should receive these from whoever administrates your AWS account. Make sure you've got both an access key id and a secret access key. -## Setting Up +Your aws credentials should be stored in a folder located at `~/.aws`. Follow [Amazon's instructions](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files) for storing them correctly. + +### Virtualenv ``` mkvirtualenv -p /usr/local/bin/python3 notifications-api ``` +### `environment.sh` + Creating the environment.sh file. Replace [unique-to-environment] with your something unique to the environment. Your AWS credentials should be set up for notify-tools (the development/CI AWS account). -Create a local environment.sh file containing the following, updating the AWS key entries with your own values: +Create a local environment.sh file containing the following: ``` echo " export SQLALCHEMY_DATABASE_URI='postgresql://localhost/notification_api' -export SECRET_KEY='secret-key' -export DANGEROUS_SALT='dangerous-salt' -export NOTIFY_ENVIRONMENT="development" -export ADMIN_CLIENT_SECRET='notify-secret-key' +export SECRET_KEY='dev-notify-secret-key' +export DANGEROUS_SALT='dev-notify-salt' +export NOTIFY_ENVIRONMENT='development' +export ADMIN_CLIENT_SECRET='dev-notify-secret-key' export ADMIN_BASE_URL='http://localhost:6012' export FROM_NUMBER='development' -export MMG_URL="https://api.mmg.co.uk/json/api.php" +export MMG_URL='https://api.mmg.co.uk/json/api.php' export MMG_API_KEY='MMG_API_KEY' -export LOADTESTING_API_KEY="FIRETEXT_SIMULATION_KEY" -export FIRETEXT_API_KEY="FIRETEXT_ACTUAL_KEY" -export STATSD_PREFIX="FAKE_PREFIX" -export NOTIFICATION_QUEUE_PREFIX="PREFIX-TO-IDENTIFY-SQS-QUEUE" -export AWS_REGION= -export AWS_ACCESS_KEY_ID= -export AWS_SECRET_ACCESS_KEY= +export LOADTESTING_API_KEY='FIRETEXT_SIMULATION_KEY' +export FIRETEXT_API_KEY='FIRETEXT_ACTUAL_KEY' +export STATSD_PREFIX='YOU_OWN_PREFIX' +export NOTIFICATION_QUEUE_PREFIX='YOUR_OWN_PREFIX' "> environment.sh ``` -NOTE: The SECRET_KEY and DANGEROUS_SALT should match those in the [notifications-admin](https://github.com/alphagov/notifications-admin) app. +NOTES: -NOTE: Also note the unique prefix for the queue names. This prevents clashing with others queues in shared amazon environment and using a prefix enables filtering by queue name in the SQS interface. + * Replace the placeholder key and prefix values as appropriate + * The SECRET_KEY and DANGEROUS_SALT should match those in the [notifications-admin](https://github.com/alphagov/notifications-admin) app. + * The unique prefix for the queue names prevents clashing with others' queues in shared amazon environment and enables filtering by queue name in the SQS interface. + +### Postgres Install [Postgres.app](http://postgresapp.com/). You will need admin on your machine to do this. -Assuming you downloaded the ZIP file to `~/Downloads` and expanded it there, you should be able to run the following to install the app: - -``` -sudo -b ~/Downloads/Postgres.app/Contents/MacOS/Postgres -``` - -This will execute the app as a background process (so you can close the terminal window and it won't stop). The install process should offer to move the app to `Applications`. - ## To run the application You need to run the api application and a local celery instance.