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 in AWS by akhtar
• 33,470 points
58 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 by MD
• 79,390 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
• 57,700 points
1,028 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
• 57,700 points
481 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 4, 2018 in AWS by Shuvodip Ghosh
1,693 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 in AWS by MD
• 79,390 points
55 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 in AWS by MD
• 79,390 points
120 views