Custom Option List for AWS IAM Profile

Hi,

I want to present IAM profile for end user to select while deploying the service catalog, Is there any way to create an Option list for the same and attach as a custom option. As checked, I could not find any such Option list or Morpheus variables to use.

Thanks

There is no native way. However, you could use the Python module boto3 in a script to get the IAM profiles you desire and have it generate a manual option list via the Morpheus API. The Python task could be run as a nightly job to keep your list up to date within the last 24 hours. Others may have a more elegant solution.
I would generally recommend professional services for something like this.

Can try this GitHub - spoonboy-io/switch: Preprocess JSON to name and value keys for Morpheus

Thank you for the info. Let me try.

Please try the below REST call
/api/options/amazon/amazonInstanceProfiles?zoneId=8

Hello Community,

I have been trying to use the URL : … /api/options/amazon/amazonInstanceProfiles?zoneId=49 in an OptionList REST call but it is not working…

Result set is No Options Found. Using Morpheus version 5.4.11

When invoking directly in a curl the output shows…
curl --request GET \

 --url https://<base_url>/api/options/amazon/amazonInstanceProfiles?zoneId=49 \
 --header 'accept: application/json' \
 --header 'authorization: Bearer <token>'

{“success”:true,“data”:[{“name”:“Profile1”,“value”:“Value1”},{“name”:“Profile2”,“value”:“Value-2”}]}

Using the below in both request and translation script ( in fact tried all combinations just translation, just request but still doesn’t work)
for (var x = 0; x < data.length; x++) {
results.push({name:data.name, value:data.value});
}

My larger goal is to have IAM instance profiles be populated based on the Cloud selected in the catalog. if I can make the above working… next step would be to making REST query dynamic in nature.

Hello Sanin,

Please use the below translation script.

for(var i=0; i<data.data.length; i++) {
results.push({name: data.data[i].name, value: data.data[i].name});
}

Thanks
Velan

Thank you @vsenthilkarasu for this and further support in making the query generic.

Below I am capturing how this was achieved.

I have also made the Option List Generic as below… This allows the filters of the IAM profile based on the Cloud selected which is also a dependent field of my iam-profile input (input.cloudlist)

URL: https://base-url/api/options/amazon/amazonInstanceProfiles

Translation Script with some filters

if (input.cloudlist) {     

  for(var i=0; i<data.data.length; i++) {
    
    var dataName = data.data[i].name
    if (dataName.search(/^Exact-Profile-1$|Profile-2|Profile-3/i) > -1) {  
		results.push({name: data.data[i].name, value: data.data[i].value});
    }
    
  }
}

Request Script as

if (input.cloudlist) {     
    results=[{name: "zoneId",value: input.cloudlist}]
}