Skip to content
OPG API Gateway into Sirius: Managed by opg-org-infra & Terraform
Branch: master
Clone or download
Latest commit 9c75d44 May 23, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Fix terraform to v0.11 May 23, 2019
.github
docker Moved handler to a class May 14, 2019
docs
lambdas
localstack-config Updated docker-compose integrations May 13, 2019
modules Added the new DynamoDB table into the terraform Apr 17, 2019
tests Basic check of unauthorised response May 16, 2019
.envrc Lpa 3205 lpa service access (#27) Apr 5, 2019
.gitignore
.mdlrc Stand up opg-api-gateway repo and migrate terraform code (#1) Feb 8, 2019
.ruby-version
CODEOWNERS
Dockerfile
Gemfile
README.md Updated docker-compose integrations May 13, 2019
Rakefile Lpa 3205 lpa service access (#27) Apr 5, 2019
api-gateway.tf Fixed type Apr 12, 2019
config.json
credentials.tf
data_sources.tf Package Lambda for deployment (#16) Mar 7, 2019
docker-compose-integration.yml Renamed model -> response May 14, 2019
docker-compose.yml Renamed model -> response May 14, 2019
dynamodb.tf Updated cache config Apr 29, 2019
file_loader.rb Lpa 3180 api custom domain (#20) Mar 19, 2019
locals.tf Updated feature environment name May 15, 2019
lpas_collection.tf
modify_env.rb Lpa 3180 api custom domain (#20) Mar 19, 2019
products.tf
redact_output.sh Make and reference a stored secret (#19) Mar 13, 2019
security_groups.tf Standardised security groups Apr 1, 2019
simulate_sirius_access.tf Added missing lambda variable Apr 17, 2019
techdebt.md
terraform.tfvars Lpa 3180 api custom domain (#20) Mar 19, 2019
variables.tf Stand up opg-api-gateway repo and migrate terraform code (#1) Feb 8, 2019

README.md

opg-sirius-api-gateway

OPG API Gateway into Sirius: Managed by opg-org-infra & Terraform

Project build status - production

CircleCI

Working locally with Terraform

Setting Env Vars

This repository comes with an .envrc file containing useful environment variables for working with this repository.

.envrc can be sourced automatically using either direnv or manually with bash.

source .envrc

or

direnv allow

AWS Credentials Setup

You will need an AWS user that has write permissions into the accounts you want to work with See opg-org-infra/AWS-CONSOLE.md for credentials setup instructions. And also opg-new-starter/AWS-VAULT.md

Initialize Terraform

aws-vault exec identity -- terraform init -backend-config="role_arn=arn:aws:iam::311462405659:role/management-admin"

Then you can run terraform commands

aws-vault exec identity -- terraform $command

All commands through an identity account.

For example, import a resource using the following command

aws-vault exec identity -- terraform import module.any-bucket-you-own.aws_s3_bucket.bucket any-bucket-you-own

Rakefile - Shortcuts for local work

A Rakefile has been provided with commands helpful for local work.

They are effectively shortcuts, intended to be useful.

Some are used in the CI pipeline too.

Set up your environment

Make sure you have Ruby installed

ruby -v

If you need help installing ruby, see here. https://www.ruby-lang.org/en/documentation/installation/

install the bundler gem

gem install bundler

Now install the gems required for the package

bundle install

Listing the available Rake tasks

You can list the available commands in the Rake file

bundle exec rake -T
rake lambda:buildapitestfile  # Lambda: build api tests env file
rake lambda:package           # Lambda: package lambda function
rake lambda:testlpas          # Lambda: test lpas collection endpoint
rake terraform:apply          # Terraform: apply
rake terraform:plan           # Terraform: plan

Running a Rake task

For commands that require aws IAM roles, you can use aws-vault to select the correct profile (see https://github.com/ministryofjustice/opg-new-starter/blob/master/AWS-VAULT.md)

aws-vault exec identity -- bundle exec rake terraform:localplan

Testing the OPG Sirius API Gateway

Testing of the deployed api gateway is done using Postman and Newman

https://www.getpostman.com/downloads/ https://www.npmjs.com/package/newman

Install Newman

npm install -g newman

Run a test against development

aws-vault exec identity -- bundle exec rake lambda:testlpas

#Setup for local development

With Sirius

For testing with the full local Sirius stack, you need to bring OPG Gateway up at the same time as Sirius. Ensure that opg-sirius-api-gateway is cloned into the same root direct as opgs-sirius.

Then from within opgs-sirius, run:

docker-compose -f docker-compose.yml \
-f docker-compose.override.yml \
-f ../opg-sirius-api-gateway/docker-compose.yml \
-f ../opg-sirius-api-gateway/docker-compose-integration.yml up

This will give you the normal Sirius stack, plus OPG Gateway (and its dependencies).

With LPA Online Tool

For testing with the full local LPA stack, you need to bring OPG Gateway up at the same time as the tool. Ensure that opg-sirius-api-gateway is cloned into the same root direct as opg-lpa-docker.

Then from within opg-lpa-docker, run:

docker-compose -f docker-compose.yml \
-f ../opg-sirius-api-gateway/docker-compose.yml \
-f ../opg-sirius-api-gateway/docker-compose-integration.yml up

This will give you the normal Sirius stack, plus OPG Gateway (and its dependencies).

You can’t perform that action at this time.