Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29255

How to execute python script sitting on EC2 using Lambda function?

$
0
0

How to execute python script sitting on EC2 using Lambda function?

'''from_ec2.py'''

print("hello from EC2")
#################################
###lambda function

import boto3
def lambda_handler(event, context):
    instanceID = ['i-04########9']
    runscript = 'python from_ec2.py'

    ssm_client = boto3.client('ssm')
    response = ssm_client.send_command(
            InstanceIds=instanceID,
            DocumentName="AWS-RunShellScript",
            Parameters={"commands": [runscript]}, )

shows error:

aws lambda returned AccessDeniedException(caller is not authorized to call API) calling


Viewing all articles
Browse latest Browse all 29255

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>