Categorygithub.com/ONSdigital/dp-areas-api
modulepackage
0.21.0
Repository: https://github.com/onsdigital/dp-areas-api.git
Documentation: pkg.go.dev

# README

dp-areas-api

Digital Publishing areas API used to navigate profiles for different geographical areas across the UK

Getting started

  • Run make debug

Dependencies

  • No further dependencies other than those defined in go.mod

Configuration

Environment variableDefaultDescription
BIND_ADDR:25500The host and port to bind to
GRACEFUL_SHUTDOWN_TIMEOUT5sThe graceful shutdown timeout in seconds (time.Duration format)
HEALTHCHECK_INTERVAL30sTime between self-healthchecks (time.Duration format)
HEALTHCHECK_CRITICAL_TIMEOUT90sTime to wait until an unhealthy dependent propagates its state to make this app unhealthy (time.Duration format)

Connecting to the AWS AURORA RDS instance from your local machine

Note: <RDS_INSTANCE_ENDPOINT> can be obtained from the AWS AURORA RDS cluster console here:

https://eu-west-1.console.aws.amazon.com/rds/home?region=eu-west-1#database:id=develop-area-profiles-postgres;is-cluster=true

  1. Add DB host to /etc/hosts:

127.0.0.1 <RDS_INSTANCE_ENDPOINT>

  1. Set the following in your environment - remote postgres connection:
export AWS_PROFILE="development"
export PG_USER="dp-areas-api-publishing"
export PGPASSWORD="$(aws rds generate-db-auth-token --hostname 
 --port 5432 --region eu-west-1 --username dp-areas-api-publishing)"

These config variables are only required if running the dp-areas-api branch I’m working on (https://github.com/ONSdigital/dp-areas-api/tree/feature/postgres_healthcheck):

export DBNAME="dp-areas-api"
export DBUSER="dp-areas-api-publishing"
export DBHOST="<RDS_INSTANCE_ENDPOINT>"
export DBPORT=5432
export AWSREGION=<AWS_REGION>

for local postgres connection (relies on dp-compose):

Note: set DPPostgresLocal to true to use local postgres instance

export DPPostgresLocal=true
export DPPostgresUserName="postgres"`
export DPPostgresUserPassword="<PASSWORD>"` (see docker compose)
export DPPostgresLocalPort="5432"`
export DPPostgresLocalDB="dp-areas-api"`
  1. Run the dp command:
dp remote allow develop
  1. Open a port forwarding connection from your localhost:5432 to the AWS AURORA RDS instance endpoint by running:
dp ssh develop publishing 3 -v -- -L 5432:<RDS_INSTANCE_ENDPOINT>:5432
  1. Get the required certificate by running:
wget https://s3.amazonaws.com/rds-downloads/rds-ca-2019-root.pem
  1. Finally, execute the sql command to open a tunnel to the AWS AURORA RDS instance:
psql -h url to rds instance -p 5432 "sslmode=verify-full sslrootcert="rds-ca-2019-root.pem" dbname=dp-areas-api user=dp-areas-api-publishing"

Add env variable to import area info

export CSV_FILE_PATH="<CSV_FILE_PATH>"
export AREA_UPDATE_URL=http://127.0.0.1:25500/v1/areas/

Contributing

See CONTRIBUTING for details.

License

Copyright © 2021, Office for National Statistics (https://www.ons.gov.uk)

Released under MIT license, see LICENSE for details.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

BuildTime represents the time in which the service was built.
GitCommit represents the commit (SHA-1) hash of the service that is running.
Version represents the version of the service that is running.