Create a key pair in AWS using Boto3

0 votes

Hi Team,

I am new to the Boto3 module. I want to create a key pair in AWS. How can I do that with boto3? 

Oct 8, 2020 in AWS by akhtar
• 38,260 points
1,866 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to create a 2048-bit RSA key pair with the specified name. Amazon EC2 stores the public key and displays the private key for you to save to a file. The private key is returned as an unencrypted PEM encoded PKCS#8 private key. If a key with the specified name already exists, Amazon EC2 returns an error.

import boto3
ec2 = boto3.client('ec2')
response = ec2.create_key_pair(KeyName='KEY_PAIR_NAME')
print(response)
answered Oct 8, 2020 by MD
• 95,460 points

Related Questions In AWS

0 votes
1 answer

How can I disable a user's password in AWS using boto3

delete_login_profile is the one you should use if ...READ MORE

answered Sep 27, 2018 in AWS by Priyaj
• 58,020 points
3,094 views
0 votes
1 answer

Pass account id of an AWS sub account using a variable as an argument in CloudWatch Alarm Actions with python (boto3)?

Python String and Integer concatenation >>> print("arn:aws:swf:us-east-2:{0}:action/actions/AWS_EC2.InstanceId.Stop/1.0".format(acccnum)) arn:aws:swf:us-east-2:12312312312312:action/actions/AWS_EC2.InstanceId.Stop/1.0 >>> print("arn:aws:swf:us-east-2:" ...READ MORE

answered Oct 5, 2018 in AWS by Priyaj
• 58,020 points
1,600 views
0 votes
1 answer

How to create subnets in a vpc using boto3?

Here is the simple way of implementing ...READ MORE

answered Dec 5, 2018 in AWS by Shuvodip Ghosh
4,624 views
0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer

How to create a VPC in AWS using Boto3?

Hi@akhtar, Amazon Web Services enables you to create ...READ MORE

answered Oct 9, 2020 in AWS by MD
• 95,460 points
1,684 views
0 votes
1 answer

How to describe a key pair using Boto3?

Hi@akhtar, You can find one method in your ...READ MORE

answered Oct 8, 2020 in AWS by MD
• 95,460 points
1,582 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP