Passing Security Group input from forms in AWS catalog config

If you’re using a security group input in a form that is attached to a catalog and you need to reference that security group input in the catalog configuration, the following configuration might not work as expected:

“securityGroups”: [
{
“id”: “<%= customOptions.sg%>”
}
]

As a workaround, you can use the following Groovy snippet to properly parse and utilize the security group input:

“securityGroups”: [
{
“id”: “<%= new groovy.json.JsonSlurper().parseText(customOptions.sg?.toString())?.getAt(0)?.id%>”
}
]

Thanks
Velan

1 Like

Removing the quotes should do the job too

1 Like
"securityGroups": <%= customOptions.sg%>

This will also work as a solution. It will automatically insert the array of security group IDs selected during the catalog item order.

Please note this is assuming you have set the field name of the form option to be “sg”.

1 Like