# EC2 Dynamic Inventory For Keyed Group Help

**URL:** <https://forum.ansible.com/t/ec2-dynamic-inventory-for-keyed-group-help/1862>\
**Category:** Get Help\
**Tags:** aws\
**Created:** [October 23, 2023, 2:20am UTC](https://forum.ansible.com/t/ec2-dynamic-inventory-for-keyed-group-help/1862 "2023-10-23T02:20:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ku1918](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@ku1918](https://forum.ansible.com/u/ku1918)\
**Post date:** [October 23, 2023, 2:20am UTC](https://forum.ansible.com/t/ec2-dynamic-inventory-for-keyed-group-help/1862/1 "2023-10-23T02:20:04Z")

</div>

Hi,

I would to ask if anyone know how to escape colon?

```auto
---
assume_role_arn: arn:aws:iam::xxx:role/role
keyed_groups:
  - key: tags.environment
    separator: ""
  - key: platform_details
    separator: ""
  - key: state.name
    separator: ""
  - key: tags.{% raw %}aws:autoscaling:groupName{% endraw %}
    separator: ""
    prefix: asg
compose:
 ansible_host: private_ip_address

```

The problem is when I sync inventory , i can’t get all the host group by the autoscaling group name.

I suspect is due to the “:” issue.

Please assist if anyone know.

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [October 24, 2023, 2:18pm UTC](https://forum.ansible.com/t/ec2-dynamic-inventory-for-keyed-group-help/1862/2 "2023-10-24T14:18:57Z")

</div>

While the two types of accessors in Jinja are often interchangeable, `.` as an accessor can only be used with valid Python identifiers. For keys that do not adhere to the rules for identifiers you have to use square brackets.

```auto
  - key: tags['aws:autoscaling:groupName']
    separator: ""
    prefix: asg

```
