Skip to main content

NHS Digital Spine Core common AWS code

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

spine-core-aws-common

Common code used across Spine projects in AWS

[!IMPORTANT] The spine-core-aws-common python package is no longer supported. The package and its source code will remain publicly available but no further development is planned.

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


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.16.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spine_aws_common-0.2.16-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

Details for the file spine_aws_common-0.2.16.tar.gz.

File metadata

  • Download URL: spine_aws_common-0.2.16.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for spine_aws_common-0.2.16.tar.gz
Algorithm Hash digest
SHA256 841e9f389ccba1804d07755069704eb870a336d576ee6dbf525fd6675876e82e
MD5 6154020bcf7e76ea00c014223698fdfd
BLAKE2b-256 523f90a2c2f5392b4f13b92d7f60faff3a22b6b32cd78e51ee1c7b683c0d69a4

See more details on using hashes here.

File details

Details for the file spine_aws_common-0.2.16-py3-none-any.whl.

File metadata

File hashes

Hashes for spine_aws_common-0.2.16-py3-none-any.whl
Algorithm Hash digest
SHA256 3f9c4fbd11a7644daed3fd2fbbc4dec121682b817c7926d4bd785291bcea9e6a
MD5 31c894513c547878ee49c40b4559a02d
BLAKE2b-256 c504727f2702786ec4fafb11de744e3b95053c87cfea7c13d467aa2ce04cd716

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page