boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
9.03k stars 1.87k forks source link

"Unknown service: 'rds-data'. #1896

Closed blakedobbs closed 5 years ago

blakedobbs commented 5 years ago

Lambda function generating the below:

errorMessage": "Unknown service: 'rds-data'. Valid service names are: acm, acm-pca, alexaforbusiness, apigateway, application-autoscaling, appstream, appsync, athena, autoscaling, autoscaling-plans, batch, budgets, ce, chime, cloud9, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codebuild, codecommit, codedeploy, codepipeline, codestar, cognito-identity, cognito-idp, cognito-sync, comprehend, config, connect, cur, datapipeline, dax, devicefarm, directconnect, discovery, dlm, dms, ds, dynamodb, dynamodbstreams, ec2, ecr, ecs, efs, eks, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, firehose, fms, gamelift, glacier, glue, greengrass, guardduty, health, iam, importexport, inspector, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click-projects, iotanalytics, kinesis, kinesis-video-archived-media, kinesis-video-media, kinesisanalytics, kinesisvideo, kms, lambda, lex-models, lex-runtime, lightsail, logs, machinelearning, macie, marketplace-entitlement, marketplacecommerceanalytics, mediaconvert, medialive, mediapackage, mediastore, mediastore-data, mediatailor, meteringmarketplace, mgh, mobile, mq, mturk, neptune, opsworks, opsworkscm, organizations, pi, pinpoint, pinpoint-email, polly, pricing, rds, redshift, rekognition, resource-groups, resourcegroupstaggingapi, route53, route53domains, s3, sagemaker, sagemaker-runtime, sdb, secretsmanager, serverlessrepo, servicecatalog, servicediscovery, ses, shield, signer, sms, snowball, sns, sqs, ssm, stepfunctions, storagegateway, sts, support, swf, transcribe, translate, waf, waf-regional, workdocs, workmail, workspaces, xray", "errorType": "UnknownServiceError", "stackTrace": [ " File \"/var/task/lambda_function.py\", line 5, in lambda_handler\n client = boto3.client('rds-data')\n",

Gav76 commented 5 years ago

The version of boto3 included in Lambda is 1.7.74 (see here

and the rds-data was introduced in a newer version. If you need it, ship the boto3 version you require with your Lambda then it should work

JordonPhillips commented 5 years ago

Just so! Also make sure you're bundling in botocore.

no-response[bot] commented 5 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Dani-x2 commented 5 years ago

I am having the same issue:

Boto3 version: 1.9.42 Runtime: Python 3.7 Lambda inline code:

import json
import botocore
import boto3

def lambda_handler(event, context):
    print("::: boto3 version: "+boto3.__version__)
    client = boto3.client("rds-data")
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Error displayed:


Response:
{
  **"errorMessage": "Unknown service: 'rds-data'.** Valid service names are: acm, acm-pca, alexaforbusiness, apigateway, application-autoscaling, appstream, appsync, athena, autoscaling, autoscaling-plans, batch, budgets, ce, chime, cloud9, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codebuild, codecommit, codedeploy, codepipeline, codestar, cognito-identity, cognito-idp, cognito-sync, comprehend, config, connect, cur, datapipeline, dax, devicefarm, directconnect, discovery, dlm, dms, ds, dynamodb, dynamodbstreams, ec2, ecr, ecs, efs, eks, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, firehose, fms, gamelift, glacier, glue, greengrass, guardduty, health, iam, importexport, inspector, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click-projects, iotanalytics, kinesis, kinesis-video-archived-media, kinesis-video-media, kinesisanalytics, kinesisvideo, kms, lambda, lex-models, lex-runtime, lightsail, logs, machinelearning, macie, marketplace-entitlement, marketplacecommerceanalytics, mediaconvert, medialive, mediapackage, mediastore, mediastore-data, mediatailor, meteringmarketplace, mgh, mobile, mq, mturk, neptune, opsworks, opsworkscm, organizations, pi, pinpoint, pinpoint-email, polly, pricing, rds, redshift, rekognition, resource-groups, resourcegroupstaggingapi, route53, route53domains, s3, sagemaker, sagemaker-runtime, sdb, secretsmanager, serverlessrepo, servicecatalog, servicediscovery, ses, shield, signer, sms, snowball, sns, sqs, ssm, stepfunctions, storagegateway, sts, support, swf, transcribe, translate, waf, waf-regional, workdocs, workmail, workspaces, xray",
  "errorType": "UnknownServiceError",
  "stackTrace": [
    "  File \"/var/task/lambda_function.py\", line 7, in lambda_handler\n    client = boto3.client(\"rds-data\")\n",
    "  File \"/var/runtime/boto3/__init__.py\", line 91, in client\n    return _get_default_session().client(*args, **kwargs)\n",
    "  File \"/var/runtime/boto3/session.py\", line 263, in client\n    aws_session_token=aws_session_token, config=config)\n",
    "  File \"/var/runtime/botocore/session.py\", line 809, in create_client\n    client_config=config, api_version=api_version)\n",
    "  File \"/var/runtime/botocore/client.py\", line 69, in create_client\n    service_model = self._load_service_model(service_name, api_version)\n",
    "  File \"/var/runtime/botocore/client.py\", line 104, in _load_service_model\n    api_version=api_version)\n",
    "  File \"/var/runtime/botocore/loaders.py\", line 132, in _wrapper\n    data = func(self, *args, **kwargs)\n",
    "  File \"/var/runtime/botocore/loaders.py\", line 378, in load_service_model\n    known_service_names=', '.join(sorted(known_services)))\n"
  ]
}

Request ID:
"bfa81552-d379-4e02-bd37-29d2caf34122"

Function Logs:
START RequestId: bfa81552-d379-4e02-bd37-29d2caf34122 Version: $LATEST
**::: boto3 version: 1.9.42**
[ERROR] **UnknownServiceError: Unknown service: 'rds-data'.** Valid service names are: acm, acm-pca, alexaforbusiness, apigateway, application-autoscaling, appstream, appsync, athena, autoscaling, autoscaling-plans, batch, budgets, ce, chime, cloud9, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codebuild, codecommit, codedeploy, codepipeline, codestar, cognito-identity, cognito-idp, cognito-sync, comprehend, config, connect, cur, datapipeline, dax, devicefarm, directconnect, discovery, dlm, dms, ds, dynamodb, dynamodbstreams, ec2, ecr, ecs, efs, eks, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, firehose, fms, gamelift, glacier, glue, greengrass, guardduty, health, iam, importexport, inspector, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click-projects, iotanalytics, kinesis, kinesis-video-archived-media, kinesis-video-media, kinesisanalytics, kinesisvideo, kms, lambda, lex-models, lex-runtime, lightsail, logs, machinelearning, macie, marketplace-entitlement, marketplacecommerceanalytics, mediaconvert, medialive, mediapackage, mediastore, mediastore-data, mediatailor, meteringmarketplace, mgh, mobile, mq, mturk, neptune, opsworks, opsworkscm, organizations, pi, pinpoint, pinpoint-email, polly, pricing, rds, redshift, rekognition, resource-groups, resourcegroupstaggingapi, route53, route53domains, s3, sagemaker, sagemaker-runtime, sdb, secretsmanager, serverlessrepo, servicecatalog, servicediscovery, ses, shield, signer, sms, snowball, sns, sqs, ssm, stepfunctions, storagegateway, sts, support, swf, transcribe, translate, waf, waf-regional, workdocs, workmail, workspaces, xray
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 7, in lambda_handler
    client = boto3.client("rds-data")
  File "/var/runtime/boto3/__init__.py", line 91, in client
    return _get_default_session().client(*args, **kwargs)
  File "/var/runtime/boto3/session.py", line 263, in client
    aws_session_token=aws_session_token, config=config)
  File "/var/runtime/botocore/session.py", line 809, in create_client
    client_config=config, api_version=api_version)
  File "/var/runtime/botocore/client.py", line 69, in create_client
    service_model = self._load_service_model(service_name, api_version)
  File "/var/runtime/botocore/client.py", line 104, in _load_service_model
    api_version=api_version)
  File "/var/runtime/botocore/loaders.py", line 132, in _wrapper
    data = func(self, *args, **kwargs)
  File "/var/runtime/botocore/loaders.py", line 378, in load_service_model
    known_service_names=', '.join(sorted(known_services)))
END RequestId: bfa81552-d379-4e02-bd37-29d2caf34122
REPORT RequestId: bfa81552-d379-4e02-bd37-29d2caf34122  Duration: 623.45 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 73 MB  Init Duration: 234.15 ms    
XRAY TraceId: 1-5d849ff1-cf38b7745ddc2f5e2f942a9e   SegmentId: 00eefc87676e117a Sampled: false
koacapital commented 5 years ago

I'm experiencing the same issue here.

Dani-x2 commented 5 years ago

I am trying to use the "ship the boto3 version you require with your Lambda" approach.

It works locally, but once uploaded to the Lambda, it does not.

Because Boto3 is already in the Lambda, I think Python do not use the one I "ship". I have tried to rename my local Boto3 to a different name to make sure Lambda uses the one I upload, but this is....nasty, still does not work and I do not really like this approach.

Dani-x2 commented 5 years ago

Ok, I finally managed to do it. Changing names was a bad idea indeed. I was desperate haha. But I was on the right track. Lambda was loading its own Boto3, the old one, not the one I was sending.

The best approach to work this out is creating a Layer with the right version of Boto3 (thanks @alexx666 for your help)

Step 1: In an empty folder write this:

python -m venv python
source python/Script/activate   //maybe activate is inside other folder for you
pip install boto3
pip freeze > requirements.txt

Step 2: now create a .zip out of the python folder.

Step 3: go to your Lambda console website, and go to Layers > Create Layer

Step 4: inside your Lambda > Functions, in the Designer diagram, click on "Layers". Then "Add a layer" and select the one you created in step 3.

Step 5: In the Function code area you can test everything with this code:

import boto3

def lambda_handler(event, context):
    print("::: boto3 version = "+boto3.__version__)
    client = boto3.client("rds-data", region_name="eu-west-1")
    print("If you can read this, it's because we finally did it! ")