08/15/2023 01:47 PM
Hi team,
I'm trying to create and grant access to a db account. I'm able to create account but grant access is failing in the same request.
GrantaccessJSON:
{"Roles": "${if(arsTasks.entitlement_valueKey.entitlement_value.toString().contains('#Y#Y#Y#Y')){'GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO '${accountName}'@'%';'} else {'GRANT SELECT ON *.* TO '${accountName}'@'%';'}}"}
Error in the provision comment:
Error while assigning access - trust4_poc_docker#Y#N#N#N to account - dpzkr -dpzkr-Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript14888.groovy: 1: expecting '}', found '@' @ line 1, column 152. LETE ON *.* TO '${accountName}'@'%';'} e ^ 1 error
Appreciate the help. TIA
Solved! Go to Solution.
08/15/2023 09:11 PM - edited 08/22/2023 01:15 AM
Hello @prashanthreddy,
Try with the below queries,
{ "Roles":
"${if(arsTasks.entitlement_valueKey.entitlement_value.toString().contains('#Y#Y#Y#Y')){'GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO '${accountName}''{{@}}''%';'} else {'GRANT SELECT ON *.* TO '${accountName}''{{@}}''%';'}}"
}
or
{"Roles" : "${task.entitlement_valueKey.entitlement_value.toString().contains('#Y#Y#Y#Y')?'GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO \"'+accountName+'\";':'GRANT SELECT ON *.* TO \"'+accountName+'\";'}"}
Thanks,
08/17/2023 07:19 AM
Hi Sudesh,
Thanks for the response but for the first json I see this error:
Error while assigning access - trust4_poc_docker#Y#N#N#N to account - dpigr -dpigr-Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed: SimpleTemplateScript22650.groovy: 1: Ambiguous expression could be either a parameterless closure expression or an isolated open code block; solution: Add an explicit closure parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...} @ line 1, column 166. E ON *.* TO '${accountName}''{{@}}''%';' ^ 1 error
And for the second one :
Error while assigning access - trust4_poc_docker#Y#N#N#N to account - dpjrl -dpjrl-No such property: entitlement_valueKey for class: java.lang.String
08/17/2023 07:43 AM
Hello @prashanthreddy,
Can you please try with the below query,
{
"Roles": "${if(arsTasks.entitlement_valueKey.entitlement_value.toString().contains('#Y#Y#Y#Y')){'GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO \'' + accountName + '\'@\'%\';'} else {'GRANT SELECT ON *.* TO \'' + accountName + '\'@\'%\';'}}"
}
or try with the \\ as well,
{
"Roles": "${if(arsTasks.entitlement_valueKey.entitlement_value.toString().contains('#Y#Y#Y#Y')){'GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO\\'${accountName}\\'@\\'%\\';'} else {'GRANT SELECT ON *.* TO\\'${accountName}\\'@\\'%\\';'}}"
}
Thanks
08/17/2023 08:59 AM
08/17/2023 02:44 PM - edited 08/17/2023 02:50 PM
@prashanthreddy : Try this ternary operation
{"Roles" : "${task.entitlement_valueKey.entitlement_value.toString().contains('#Y#Y#Y#Y')?'GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO \"'+accountName+'\";':'GRANT SELECT ON *.* TO \"'+accountName+'\";'}"}
08/18/2023 11:44 AM
Thanks Saathvik,
It worked.