I want to connect SSH existing EC2 and execute command from lambda python(boto) code without using pem key and anything. Need to connect using IAM role. is there any way?
Asked
Active
Viewed 634 times
0
-
Can you clarify your issue or ask more specific questions? Are you trying to execute a lambda function from ec2 OR use a lambda function to connect to an ec2 instance? – MisterSmith Apr 12 '18 at 11:06
-
lambda function to connect to an ec2 – Nizamudeen Apr 12 '18 at 11:11
-
Please define what you mean by "connect to an EC2 instance" -- connect how? SSH? HTTP? What are you trying to accomplish? The more information you provide, the better the answers will be. Feel free to Edit your question to add more details. – John Rotenstein Apr 12 '18 at 11:26
1 Answers
0
Have you thought about using the AWS SSM Run command through the AWS API instead of trying to SSH?
You can setup a command to run in AWS that can be called by your Lambda function through the AWS API. You assign a role to the Lambda function allowing it access to the SSM command.
Previous answer details how to setup SSM: launch a shell script from lambda in aws

MisterSmith
- 2,884
- 1
- 10
- 13