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