PRECONDITION
Today let’s see how to import the paramiko library into AWS Lambda with this errors: from_buffer() cannot return the address of the raw string within a str or unicode or bytearray object and unable to import function etc.
PROCEDURE
For security i use an AWS instances for install the dependency, because there is python 2.7 installed and windows could create problems.
Create an instances with Amazon Linux 2 AMI and an Public IP/Elastic IP. Use ssh to enter in the machine with our private key.
Create and enter in a new directory and follow this instructions:
Now zip this folder
and copy this zip in our local pc by scp.
Remember to insert your python file in the zip where you import the python paramiko library.
This is an example to use the paramiko library for get and put a file in two different server by sftp:
In this other example we save the file downloaded in a S3 bucket and save it by aws cli in the instances (identified by tag):
Import the zip in the lambda, use python 2.7, specify the name and file of where you import your code:

The policy for the lambda function:
EC2 filtered by tag
S3
SSM
For the role to attach at the instance:
S3
SSM
CONCLUSIONS
Let us know if you have solved the problem!
How to pass AWS Solution Architect certification?
AWS Certified Solutions Architect Training Notes 2020: https://amzn.to/2ZAGQpa
AWS Certified Solutions Architect Associate Practice Tests: https://amzn.to/2Zz8sef
Leave A Comment