Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

How to get boto3 authorization on AWS Lambda without uploading a zip file

Looking at the boto3 authentication scheme it seems like it uses a configuration file based authentication approach.

This link suggests that to authenticate with Lambda you can simply upload your code (zipped) after installing boto3 locally. Running python with boto2 as an AWS Lambda function

I was hoping there was something simpler I could do from within the aws lambda web interface to log in.

This is the code I'm running which returns "An error occurred (AccessDeniedException) when calling the GetFunction operation"

import json
import boto3

def lambda_handler(event, context):
    
    client = boto3.client('lambda',region_name='us-east-2') 
    response = client.get_function(FunctionName='jims_first_function')
    return {
        'statusCode': 200,
        'body': json.dumps(response)
    }
question from:https://stackoverflow.com/questions/65623484/how-to-get-boto3-authorization-on-aws-lambda-without-uploading-a-zip-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I tried manually creating the .aws directory and associated credentials in the root directory and that failed. Not sure if that was because it wasn't in the /opt directory or not.

https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#configuration

However after a bit more digging I found this link: How should I pass my s3 credentials to Python lambda function on AWS?

Basically it indicated that I needed to be digging around the permissions tab to modify policies associated with the default role. Clicking on the role brings up the IAM policy management window. In there I clicked on "Attach Policies", selected the AWSLambda_FullAccess option, and added it (that might be overkill, not sure). I might have needed to redeploy the code, not sure. After testing everything works.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...