# Use EC2 instance ID for tag

**URL:** <https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396>\
**Category:** Cloud platforms\
**Tags:** aws, tagging\
**Created:** [July 1, 2024, 3:09pm UTC](https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396 "2024-07-01T15:09:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![avdveen](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@avdveen](https://community.dynatrace.com/u/avdveen)\
**Post date:** [July 1, 2024, 3:09pm UTC](https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396/1 "2024-07-01T15:09:15Z")

</div>

Hi, is it possible to use the AWS EC2 instance ID in a tag rule? Mine doesn’t seem to work, but I’m not sure it is possible for EC2 instances detected via CW integration only. If there’s an agent deployed, I can get it to work.

 ![andre_vdveen_0-1719846480780.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/0/20c950b3d72487a0fb04f0e9fb9ddad4f5d0010b.png)

Any ideas or suggestions are welcome! 🙂

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [July 1, 2024, 6:42pm UTC](https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396/2 "2024-07-01T18:42:47Z")

</div>

Hey [@andre\_vdveen](https://community.dynatrace.com/user/11931)&nbsp;,  
Not completely confident on this but can you try removing the spaces here? Give something like&nbsp;_ **{Ec2Instance:Name}-{Ec2Instance:InstanceId}.** &nbsp;_ Cause in most of the cases white space causes an issue while using placeholders. If you leave the tag.  
This example not exactly qualifies but this might be a hint.

 ![Maheedhar_T_0-1719859294131.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/9/59767c30a12e8e85c036ec2f9a150987907fb184.png)

Can you give it a try and confirm?

Regards,  
[@Maheedhar\_T](https://community.dynatrace.com/user/76275)

---

<div class="post-metadata">

**Author:** ![avdveen](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@avdveen](https://community.dynatrace.com/u/avdveen)\
**Post date:** [July 2, 2024, 12:15pm UTC](https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396/3 "2024-07-02T12:15:27Z")

</div>

Hi&nbsp;[@Maheedhar\_T](https://community.dynatrace.com/user/76275)&nbsp;thanks for the suggestion but it makes no difference 😞

It is strange that Dynatrace picks up the instance ID for EC2 instances where there’s no agent deployed, yet it is not able to use it for tagging rules.

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [July 2, 2024, 2:11pm UTC](https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396/4 "2024-07-02T14:11:12Z")

</div>

Ah.!&nbsp;  
So you say that there is no one agent deployed on this host ?

---

<div class="post-metadata">

**Author:** ![avdveen](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@avdveen](https://community.dynatrace.com/u/avdveen)\
**Post date:** [July 2, 2024, 3:32pm UTC](https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396/5 "2024-07-02T15:32:35Z")

</div>

Correct.

The optional tag value populates in cases where the OneAgent is deployed on the EC2 instance, but for those that doesn’t have the agent, you still see the instance ID under properties and tags as metadata (under the AWS CloudWatch monitoring views), but it cannot be used for tags. The latter is where we’d like to use it, but it appears that it just isn’t possible.

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [July 2, 2024, 7:54pm UTC](https://community.dynatrace.com/t/use-ec2-instance-id-for-tag/46396/6 "2024-07-02T19:54:46Z")

</div>

Ah..!! I didn’t know this.  
Thanks&nbsp;[@andre\_vdveen](https://community.dynatrace.com/user/11931)
