Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AWS by (5.6k points)

I have been writing an AWS Lambda that will do an RDS Oracle SQL SELECT and will email the results. So I have been using the Lambda Management Console, but all the examples I have come across talk about making a Lambda Deployment Package. So can I do this from the Lambda Management Console?

Also What to import for the Oracle DB API?

After writing the above I dug into the boto3 API reference and came up with:

import boto3

client = boto3.client('rds-data')

But it gives the error: Unknown service: 'rds-data'.

Any suggestions would be greatly appreciated.

1 Answer

0 votes
by (12.4k points)

AWS Lambda is using an older version of boto3, which does not have rds-data yet.

You will have to create a deployment package containing a more recent version of boto3.

One way to do this would be to:

Create your lambda handler file (in this case named index.py).

def my_handler(event, context):

    client = boto3.client('rds-data')

    print(client)

    # do stuff

    return "hello world"

Add a requirements.txt file in the same folder, which will contain something like:

awscli >= 1.16.118

boto3 >= 1.9.108

Now run this (you can use pip instead of pip3) in the directory of your index and requirement file:

pip3 install -r requirements.txt -t . 

zip -r somezipname .

Next, upload this zip and change your handler 'entry point' to index.my_handler. The code should now run without errors.

Want to learn more about AWS, then do check out AWS Course offered by Intellipaat.

Related questions

0 votes
1 answer
Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...