NHS Digital Spine Core common AWS code
Project description
spine-core-aws-common
Common code used across Spine projects in AWS
Installation
Simply add the pre-built package to your python environment.
The latest version can be obtained with the following curl command if your system has it present:
package_version=$(curl -SL https://github.com/NHSDigital/spine-core-aws-common/releases/latest | grep -Po 'Release v\K(\d+.\d+.\d+)' | head -n1)
Or you can set a specific version:
package_version="0.2.3"
Alternatively the main page of this repo will display the latest version i.e. 0.2.3, and previous versions can be searched, which you can substitute in place of ${package_version}
in the below commands.
PIP
pip install https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl
requirements.txt
https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl
Poetry
poetry add https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl
Usage
TBC
Quick example
from spine_aws_common import LambdaApplication
class MyApp(LambdaApplication):
def initialise(self):
# initialise
return
def start(self):
# do actual work
# to set response for the lambda
self.response = '{"my new response":true}'
return
# create instance of class in global space
# this ensures initial setup of logging/config is only done on cold start
app = MyApp(additional_log_config='/path/to/mylogconfig.cfg')
def lambda_handler(event, context):
return app.main(event, context)
API Gateway example
from spine_aws_common import APIGatewayApplication
from aws_lambda_powertools.event_handler.api_gateway import Response
class MyApp(APIGatewayApplication):
def get_hello(self):
return Response(
status_code=200, content_type="application/json", body='{"hello":"world"}'
)
def get_id(self, _id):
response_dict = {"id": _id}
return Response(
status_code=200,
content_type="application/json",
body=json.dumps(response_dict),
)
def configure_routes(self):
self._add_route(self.get_hello, "/hello")
self._add_route(self.get_id, "/id/<_id>")
# create instance of class in global space
# this ensures initial setup of logging/config is only done on cold start
app = MyApp(additional_log_config='/path/to/mylogconfig.cfg')
def lambda_handler(event, context):
return app.main(event, context)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spine_aws_common-0.2.13rc1.tar.gz
(30.0 kB
view hashes)
Built Distribution
Close
Hashes for spine_aws_common-0.2.13rc1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1456191ffaae198118ed2f3b5e24319778259887dd2ac90d114bf1be7cc0f24c |
|
MD5 | 542f985d5ae12ba583400d7ff72f48db |
|
BLAKE2b-256 | 59a26c7a99438102a7073cc7938a6574c80fa995fc6c1c8255fa651dafa8a53e |
Close
Hashes for spine_aws_common-0.2.13rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fadb1c3cd25f4ac95356623284580d5900ce42866dc86b082969974812d95b3 |
|
MD5 | 5160ea0206efdcd2aece78d390844261 |
|
BLAKE2b-256 | 8abfbc8eb388caf3716c9a75c45e3942d9da160f220a5a6cba59990821e02df3 |