No endpoints ruleset found for service medical-imaging, falling back to legacy endpoint routing

0

I have deployed a project using AWS CDK, and I have a lambda function which uses Boto3 to establish connection to the Health Imaging service however I get the following message and the lambda does not proceed further. Below is the code which connects to Health Imaging

import os
import shutil
import boto3
from botocore.config import Config

class miClientFactory(object):
    def __init__(self) -> None:
        pass

    def __new__(self , endpoint_url : str = None):
        inject_host_prefix = False
        os.environ['AWS_DATA_PATH'] = "/tmp"
        serviceModelPath = '/tmp/medical-imaging/2023-03-30'
        os.makedirs(serviceModelPath, exist_ok=True)
        try:
            shutil.copyfile('/opt/python/service-2.json', '/tmp/medical-imaging/2023-03-30/service-2.json')
        except Exception as err:
            print(err)
        try:
            endpoint_url= os.environ['AHLI_ENDPOINT']
            if( endpoint_url == ''):
                endpoint_url = None
                inject_host_prefix = True

        except:
            endpoint_url=None 
        session = boto3.Session()
        session._loader.search_paths.extend(["/tmp"])
        miClient = boto3.client('medical-imaging', endpoint_url=endpoint_url , config=Config(inject_host_prefix=inject_host_prefix)) 
        return miClient

This is the line of code that invokes the above class lambda layer

miclient = miClientFactory.miClientFactory()

Any help would be appreciated, Thanks

Ronak
asked 6 months ago179 views
3 Answers
1

Hi. The HealthImaging APIs were introduced in boto3 v1.28.6 . As such - the default Lambda runtimes currently available (as of Dec 2023) do not include those APIs. Those will be updated with the next released runtime version, but until then - you have a few options.

Firstly, you can continue using your code - but simply update to the current model file and production endpoints. You can find those here . However, that does mean that you will need to continue having to manage the Endpoint configuration yourself. To avoid that, and use the automatically provided endpoints - you can use a Lambda layer to bring in either an updated boto3 or just the HealthImaging model, as described in the Loaders reference . I would probably choose the last method (model only layer) as you can continue using the default runtimes, and only add a very lightweight layer to your Lambdas.

The steps to accomplish that would roughly be:

  1. Create the layer zip file following the directory structure described in the loaders reference. (eg. models/medical-imaging/2023/07/19/service-2.json).
  2. Upload the layer zip file and add it to your Lambda function. The content of the zip file will be uzipped under the "/opt" directory on the Lambda function filesystem. More info on Lambda layers here.
  3. Add an environment variable to the Lambda called 'AWS_DATA_PATH' with a value of '/opt/models'. This specifies the additional search path for the loader.
AWS
JordanK
answered 5 months ago
0

Hi there, you are still using the model files and boto client configuration specific to the preview of our service. HealthImaging is now Generally Available as of 7/26/23; the preview plus model is no longer valid and there is no longer any need to configure boto with the old model file. The AWS SDK now has medical-imaging service officially available. As part of the GA launch, HealthImaging changed endpoints. Upgrading the AWS SDK should automatically provide the correct endpoint.

AWS
answered 5 months ago
0

Adding an update for those viewing this post, in recent days...Lambda runtime (Python) does, by default, now invoke a version of Boto3 that natively supports 'medical-imaging' API calls.

As Jordan pointed out that this was released (for Boto3) in version 1.28.6, and very likely, if you create a Lambda function now, you'll receive a higher version of Boto3 (1.34.42+).

Also, if you want to check the version of Boto3 and Boto3 core, you can use the below code to print out the version for verification:

import boto3
import botocore

def lambda_handler(event, context):
   print(f'boto3 version: {boto3.__version__}')
   print(f'botocore version: {botocore.__version__}')
AWS
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions