How to set access key pair or get pem file,while creating the Provision request for Amazon EC2(Provider) Instance using the manageIQ API

Passing the Rest API parameters to the Provision Request API as below ,how to set the guest_access_key_pair using API or how to login to the newly created Instance and how to find the access key pair
{
“version”: “1.1”,
“template_fields”: {
“guid”: “25d9affe-2923-41ba-aec5-3cbd26f219a5”,
“name”: “amzn2-ami-hvm-2.0.20210326.0-x86_64-gp2”,
“request_type”: “template”
} ,
“vm_fields”: {
“placement_auto”: true,
“number_of_vms”: 1,
“vm_name”: “test-dipa”,
“provision_type”: “aws”,
“vm_memory”: “1024”,
“instance_type”: 8
},

“tags”: {},
“additional_values”: null,
“ems_custom_attributes”: {
“root_password”:“xyz”,
“sysprep_password”:“xyz”
},
“miq_custom_attributes”: null
}

I’ve never tried this so I’m guessing a bit, but I would think that you’d need to get the object IDs of the key pairs in the VMDB using something like:

/api/auth_key_pairs?expand=resources&attributes=id,name

This will return something like:

{
    "name": "auth_key_pairs",
    "count": 3,
    "subcount": 3,
    "pages": 1,
    "resources": [
        {
            "href": "https://x.x.x.x/api/auth_key_pairs/30",
            "id": "30",
            "name": "aws1"
        },
         ...

Then I would think in the “vm_fields” section of your provision request API call, add something like the following (using the example of ID 30 from the previous call for the access pair):

"guest_access_key_pair": "30"

Try it, my apologies if it doesn’t work, I haven’t played with AWS provisioning much.
pemcg

Hi pemcg,

Thanks a lot for your reply ,it really worked .

Thanks,
Dipanwita

:+1: