Get item from list

Hi have the following inside a variable:

[{u’maxDataDiskCount’: 2,
u’memoryInMB’: 3584,
u’name’: u’Standard_DS1’,
u’numberOfCores’: 1,
u’osDiskSizeInMB’: 1047552,
u’resourceDiskSizeInMB’: 7168},
{u’maxDataDiskCount’: 4,
u’memoryInMB’: 7168,
u’name’: u’Standard_DS2’,
u’numberOfCores’: 2,
u’osDiskSizeInMB’: 1047552,
u’resourceDiskSizeInMB’: 14336},
{u’maxDataDiskCount’: 8,
u’memoryInMB’: 14336,
u’name’: u’Standard_DS3’,
u’numberOfCores’: 4,
u’osDiskSizeInMB’: 1047552,
u’resourceDiskSizeInMB’: 28672},
{u’maxDataDiskCount’: 16,
u’memoryInMB’: 28672,
u’name’: u’Standard_DS4’,
u’numberOfCores’: 8,
u’osDiskSizeInMB’: 1047552,
u’resourceDiskSizeInMB’: 57344},
{u’maxDataDiskCount’: 4,
u’memoryInMB’: 14336,
u’name’: u’Standard_DS11’,
u’numberOfCores’: 2,
u’osDiskSizeInMB’: 1047552,
u’resourceDiskSizeInMB’: 28672}]

I need to get to a given object based on ‘name’

Sorry, this is probably super-easy but I’m strugglig like **** with advanced jinja stuff.

btw, I’m able to do this if I use a separate template file:

{% for vm in arm_vm_details %}
{% if vm.name == vm_size %}
print ‘hello {{ vm.maxDataDiskCount }}’
{% endif %}
{% endfor %}

However, that seems like an uneccessary number of steps, as I simply want to get to the correct values for my given vm size (name). If anyone

I think the following is roughly equivalent. I haven’t tested it, so there may be some tweaks needed.

{{ (arm_vm_details|selectattr(‘name’, ‘equalto’, vm_size)|first).maxDataDiskCount }}